* {
    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 100%);
    min-height: 100vh;
    color: #e0e0e0;
    display: flex;
    flex-direction: column;
}

.container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.mode {
    width: 100%;
    max-width: 600px;
    animation: fadeIn 0.3s ease;
}

.mode.hidden {
    display: none;
}

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

/* Setup Mode */
h1 {
    font-size: 3rem;
    text-align: center;
    margin-bottom: 0.5rem;
}

h2 {
    font-size: 1.8rem;
    text-align: center;
    margin-bottom: 1rem;
}

.subtitle {
    text-align: center;
    color: #888;
    margin-bottom: 2rem;
    font-size: 1.2rem;
}

.api-key-section, .question-section {
    background: rgba(255, 255, 255, 0.05);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #aaa;
}

input[type="text"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 12px;
    border: 1px solid #333;
    border-radius: 8px;
    background: #1a1a2e;
    color: #fff;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #6c63ff;
}

.hint {
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.5rem;
    text-align: center;
}

.primary-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #6c63ff 0%, #4834d4 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(108, 99, 255, 0.4);
}

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

.secondary-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    color: #888;
    border: 1px solid #333;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: border-color 0.2s, color 0.2s;
}

.secondary-btn:hover {
    border-color: #6c63ff;
    color: #ccc;
}

.link-result {
    background: rgba(108, 99, 255, 0.1);
    padding: 1.5rem;
    border-radius: 12px;
    margin-top: 1rem;
    border: 1px solid rgba(108, 99, 255, 0.3);
}

.link-result.hidden {
    display: none;
}

.link-result input {
    margin-bottom: 0.5rem;
}

#copy-btn {
    padding: 10px 20px;
    background: #333;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}

#copy-btn:hover {
    background: #444;
}

/* Provider Selection Mode */
#provider-select-mode {
    text-align: center;
}

#provider-select-mode > p {
    color: #888;
    margin-bottom: 2rem;
}

.provider-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.provider-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid #333;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.provider-btn:hover {
    border-color: #6c63ff;
    background: rgba(108, 99, 255, 0.1);
}

.provider-btn.free {
    border-color: #4ade80;
    background: rgba(74, 222, 128, 0.1);
}

.provider-btn.free:hover {
    background: rgba(74, 222, 128, 0.2);
}

.provider-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.provider-label {
    font-size: 1.2rem;
    font-weight: 600;
    color: #fff;
}

.provider-desc {
    font-size: 0.9rem;
    color: #888;
    margin-top: 0.25rem;
}

/* Chat Animation Mode */
.chat-container {
    background: #0f0f1a;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.chat-header {
    background: linear-gradient(135deg, #6c63ff 0%, #4834d4 100%);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.provider-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

.message {
    margin-bottom: 16px;
    animation: messageIn 0.3s ease;
}

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

.message.user {
    text-align: right;
}

.message.user .bubble {
    background: linear-gradient(135deg, #6c63ff 0%, #4834d4 100%);
    color: white;
    display: inline-block;
    padding: 12px 16px;
    border-radius: 16px 16px 4px 16px;
    max-width: 80%;
    text-align: left;
}

.message.assistant .bubble {
    background: #1e1e2e;
    color: #e0e0e0;
    padding: 12px 16px;
    border-radius: 16px 16px 16px 4px;
    max-width: 90%;
    line-height: 1.6;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #1e1e2e;
    border-radius: 16px;
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #666;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50% { transform: translateY(-4px); opacity: 1; }
}

.chat-input-area {
    display: flex;
    padding: 16px;
    background: #151520;
    border-top: 1px solid #222;
    gap: 10px;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    background: #1a1a2e;
    border: 1px solid #333;
    border-radius: 24px;
    color: #fff;
    min-height: 24px;
}

.send-btn {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #6c63ff 0%, #4834d4 100%);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.send-btn:hover {
    transform: scale(1.05);
}

.snark-message {
    text-align: center;
    margin-top: 2rem;
    animation: fadeIn 0.5s ease;
}

.snark-message.hidden {
    display: none;
}

.snark-message p {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.create-own {
    color: #6c63ff;
    text-decoration: none;
}

.create-own:hover {
    text-decoration: underline;
}

.provider-info {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #333;
    color: #666;
    font-size: 0.9rem;
}

.provider-info.hidden {
    display: none;
}

/* Key Entry Mode */
#key-entry-mode {
    text-align: center;
}

#key-entry-mode h2 {
    margin-bottom: 1rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: #555;
    font-size: 0.9rem;
}

footer a {
    color: #6c63ff;
    text-decoration: none;
}

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

/* Responsive */
@media (max-width: 600px) {
    h1 {
        font-size: 2rem;
    }
    
    .chat-messages {
        min-height: 250px;
    }
}

/* Markdown styling in chat bubbles */
.markdown-body {
    text-align: left;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    margin-top: 0.5em;
    margin-bottom: 0.3em;
    font-size: 1.1em;
}

.markdown-body p {
    margin: 0.5em 0;
}

.markdown-body code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.9em;
}

.markdown-body pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 0.8em;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.5em 0;
}

.markdown-body pre code {
    background: none;
    padding: 0;
}

.markdown-body ul, .markdown-body ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.markdown-body li {
    margin: 0.2em 0;
}

.markdown-body hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    margin: 1em 0;
}

.markdown-body blockquote {
    border-left: 3px solid rgba(255, 255, 255, 0.3);
    padding-left: 1em;
    margin: 0.5em 0;
    color: rgba(255, 255, 255, 0.8);
}

.markdown-body a {
    color: #61dafb;
}
