:root {
    --bg-color: #0f0f11;
    --input-bg: #1e1e24;
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --accent-color: #6366f1;
    --hover-bg: #27272a;
    --user-msg-bg: #27272a;
    --ai-msg-text: #e4e4e7;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    position: relative;
    /* Removed padding-top here to handle in container */
}

/* Model Selector */
.model-selector {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    z-index: 1000;

    appearance: none;
    -webkit-appearance: none;
    background-color: transparent;
    /* Transparent default */
    border: 1px solid transparent;
    /* No border default */
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    padding-right: 2rem;
    border-radius: 0.75rem;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;

    /* Arrow icon */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1em;
}

.model-selector:hover,
.model-selector:focus {
    background-color: rgba(39, 39, 42, 0.8);
    /* Background on hover/active */
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.model-selector option {
    background-color: #1a1a1e;
    color: var(--text-primary);
}

.app-container {
    width: 100%;
    max-width: 768px;
    padding: 6rem 1.5rem 10rem 1.5rem;
    /* Top padding for selector, Bottom for input */
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Center content horizontally */
    min-height: 100vh;
}

.welcome-text {
    font-size: 2.5rem;
    font-weight: 600;
    text-align: center;
    margin-top: 20vh;
    margin-bottom: 2rem;
    animation: fadeIn 0.8s ease-out;
}

/* Chat History */
.chat-history {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    margin-bottom: 1rem;
}

.message {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    opacity: 0;
    animation: fadeIn 0.4s ease forwards;
}

.message.user {
    align-items: flex-end;
}

.message.assistant {
    align-items: flex-start;
}

.message-content {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    line-height: 1.6;
    font-size: 1rem;
}

.message.user .message-content {
    background-color: var(--user-msg-bg);
    color: var(--text-primary);
    border-bottom-right-radius: 0.25rem;
}

.message.assistant .message-content {
    background: transparent;
    color: var(--ai-msg-text);
    padding-left: 0;
}

/* Markdown Styles Override */
.markdown-body {
    color: inherit;
    font-family: inherit;
}

.markdown-body pre {
    background: #1e1e24;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 0.5rem 0;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.markdown-body code {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.2em 0.4em;
    border-radius: 0.3em;
}

.markdown-body pre code {
    background: transparent;
    padding: 0;
}

.markdown-body p {
    margin-bottom: 0.75rem;
}

.markdown-body p:last-child {
    margin-bottom: 0;
}

/* Input Area - FIXED Position */
.input-wrapper {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 3rem);
    /* Full width minus margins */
    max-width: 768px;
    z-index: 100;

    background-color: rgba(30, 30, 36, 0.85);
    /* Slightly transparent */
    backdrop-filter: blur(16px);
    border-radius: 1.5rem;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-wrapper:focus-within {
    box-shadow: 0 8px 40px rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.3);
    background-color: rgba(30, 30, 36, 0.95);
}

textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.05rem;
    font-family: inherit;
    resize: none;
    min-height: 24px;
    max-height: 200px;
    outline: none;
    line-height: 1.5;
}

textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

/* Controls */
.input-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.5rem;
}

.left-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.icon-btn,
.pill-btn,
.send-btn {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
}

.icon-btn:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
    transform: scale(1.1);
}

.pill-btn {
    background-color: rgba(63, 63, 70, 0.3);
    border: none;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.pill-btn:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.send-btn {
    background-color: var(--accent-color);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover:not(:disabled) {
    background-color: #4f46e5;
    transform: scale(1.1) rotate(-10deg);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

.send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.send-btn.loading {
    background-color: var(--text-secondary);
    cursor: wait;
    opacity: 0.7;
    animation: pulse 1.5s infinite;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        opacity: 0.7;
    }

    50% {
        opacity: 0.4;
    }

    100% {
        opacity: 0.7;
    }
}

.loading-dots:after {
    content: '.';
    animation: dots 1.5s steps(5, end) infinite;
}

@keyframes dots {

    0%,
    20% {
        content: '.';
    }

    40% {
        content: '..';
    }

    60% {
        content: '...';
    }

    80%,
    100% {
        content: '';
    }
}

/* Tooltips */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background-color: #000;
    color: #fff;
    font-size: 0.75rem;
    border-radius: 0.5rem;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    opacity: 0;
    animation: fadeInTooltip 0.2s ease forwards;
    pointer-events: none;
}

@keyframes fadeInTooltip {
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(-2px);
    }
}