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

:root {
--primary-color: #007AFF;
--primary-hover: #0051D5;
--background: #F5F5F7;
--surface: #FFFFFF;
--text-primary: #1D1D1F;
--text-secondary: #86868B;
--border: #D2D2D7;
--user-message: #007AFF;
--ai-message: #E8E8ED;
--shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
--shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
}

body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
background: var(--background);
color: var(--text-primary);
line-height: 1.6;
overflow-x: hidden;
}

.container {
max-width: 900px;
margin: 0 auto;
height: 100vh;
display: flex;
flex-direction: column;
background: var(--surface);
box-shadow: var(--shadow-lg);
}

header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 24px 32px;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-content h1 {
font-size: 28px;
font-weight: 600;
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 4px;
}

.logo-icon {
width: 32px;
height: 32px;
}

.subtitle {
font-size: 14px;
opacity: 0.9;
font-weight: 400;
margin-left: 44px;
}

.built-with {
color: white;
text-decoration: none;
font-size: 13px;
opacity: 0.9;
transition: opacity 0.2s;
padding: 8px 16px;
border-radius: 20px;
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
}

.built-with:hover {
opacity: 1;
background: rgba(255, 255, 255, 0.2);
}

.chat-container {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
position: relative;
}

.loading-screen {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: var(--surface);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
}

.loading-screen.hidden {
display: none;
}

.loading-content {
text-align: center;
max-width: 400px;
padding: 32px;
}

.spinner {
width: 60px;
height: 60px;
border: 4px solid var(--border);
border-top-color: var(--primary-color);
border-radius: 50%;
animation: spin 1s linear infinite;
margin: 0 auto 24px;
}

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

.loading-text {
font-size: 18px;
font-weight: 500;
margin-bottom: 8px;
color: var(--text-primary);
}

.loading-subtext {
font-size: 14px;
color: var(--text-secondary);
margin-bottom: 24px;
}

.progress-bar {
width: 100%;
height: 6px;
background: var(--border);
border-radius: 3px;
overflow: hidden;
margin-bottom: 12px;
}

.progress-fill {
height: 100%;
background: linear-gradient(90deg, var(--primary-color), var(--primary-hover));
width: 0%;
transition: width 0.3s ease;
}

.progress-text {
font-size: 13px;
color: var(--text-secondary);
font-weight: 500;
}

.chat-messages {
flex: 1;
overflow-y: auto;
padding: 24px 32px;
display: flex;
flex-direction: column;
gap: 16px;
}

.chat-messages::-webkit-scrollbar {
width: 8px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
background: var(--border);
border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
background: var(--text-secondary);
}

.message {
display: flex;
gap: 12px;
max-width: 85%;
animation: slideIn 0.3s ease;
}

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

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

.message-avatar {
width: 36px;
height: 36px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
font-weight: 600;
font-size: 14px;
}

.message.user .message-avatar {
background: var(--user-message);
color: white;
}

.message.assistant .message-avatar {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}

.message-content {
background: var(--ai-message);
padding: 12px 16px;
border-radius: 18px;
word-wrap: break-word;
line-height: 1.5;
}

.message.user .message-content {
background: var(--user-message);
color: white;
}

.message.assistant .message-content {
background: var(--ai-message);
color: var(--text-primary);
}

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

.typing-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--text-secondary);
animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
animation-delay: 0.4s;
}

@keyframes typing {
0%, 60%, 100% {
opacity: 0.3;
transform: translateY(0);
}
30% {
opacity: 1;
transform: translateY(-8px);
}
}

.input-container {
padding: 16px 32px 24px;
background: var(--surface);
border-top: 1px solid var(--border);
}

.input-wrapper {
display: flex;
gap: 12px;
align-items: flex-end;
background: var(--background);
border: 2px solid var(--border);
border-radius: 24px;
padding: 8px 12px;
transition: border-color 0.2s;
}

.input-wrapper:focus-within {
border-color: var(--primary-color);
}

#messageInput {
flex: 1;
border: none;
background: transparent;
resize: none;
outline: none;
font-family: inherit;
font-size: 15px;
color: var(--text-primary);
max-height: 120px;
padding: 8px;
}

#messageInput::placeholder {
color: var(--text-secondary);
}

#messageInput:disabled {
opacity: 0.5;
cursor: not-allowed;
}

.send-button {
width: 36px;
height: 36px;
border: none;
background: var(--primary-color);
color: white;
border-radius: 50%;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s;
flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
background: var(--primary-hover);
transform: scale(1.05);
}

.send-button:active:not(:disabled) {
transform: scale(0.95);
}

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

.send-button svg {
width: 18px;
height: 18px;
}

.input-footer {
margin-top: 8px;
text-align: center;
}

.hint {
font-size: 12px;
color: var(--text-secondary);
}

@media (max-width: 768px) {
.container {
max-width: 100%;
}

header {
padding: 16px 20px;
}

.header-content h1 {
font-size: 22px;
}

.chat-messages {
padding: 16px 20px;
}

.message {
max-width: 90%;
}

.input-container {
padding: 12px 20px 16px;
}
}