:root {
    --bg-color: #FAFAF8;
    --text-color: #1A1A1A;
    --muted: #F5F3F0;
    --muted-foreground: #6B6B6B;
    --accent: #ef6427;
    --accent-secondary: #f27f4d;
    --border: #E8E4DF;
    --card: #FFFFFF;
    --sidebar-width: 300px;
}

body {
    font-family: 'Source Sans 3', system-ui, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: row;
    height: 100vh;
    overflow: hidden;
    line-height: 1.75;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 400;
    margin: 0;
}

#sidebar {
    width: var(--sidebar-width);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    flex-shrink: 0;
}

.sidebar-header {
    height: 80px;
    box-sizing: border-box;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
}

.btn-outline {
    width: 100%;
    background-color: transparent;
    border: 1px solid var(--text-color);
    color: var(--text-color);
    padding: 0.75rem 1rem;
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 200ms ease-out;
}

.btn-outline:hover {
    background-color: var(--muted);
    border-color: var(--accent);
    color: var(--accent);
}

.chat-list {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    min-height: 0;
}

.chat-item {
    padding: 1rem 2rem;
    cursor: pointer;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.875rem;
    color: var(--muted-foreground);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
    user-select: none;
    transition: all 200ms ease-out;
    border-left: 2px solid transparent;
}

.chat-item:hover {
    background-color: var(--muted);
    color: var(--text-color);
}

.chat-item.active {
    color: var(--text-color);
    background-color: var(--card);
    border-left-color: var(--accent);
    font-weight: 500;
}

#main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: var(--bg-color);
}

header {
    height: 80px;
    box-sizing: border-box;
    padding: 0 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
}

.chat-title {
    font-size: 1.75rem;
    color: var(--text-color);
}

#chat-container {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 2rem 0;
}

.message-wrapper {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    max-width: 64rem;
}

.message-wrapper.user {
    background-color: var(--card);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.message-role {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 1rem;
}

.message-content {
    font-size: 1rem;
    color: var(--text-color);
}

.message-content p {
    margin-top: 0;
    margin-bottom: 1.5rem;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content pre {
    background-color: var(--text-color);
    color: var(--bg-color);
    padding: 1.5rem;
    overflow-x: auto;
    border-radius: 6px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.message-content code {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.875rem;
    background-color: var(--muted);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
}

.message-content pre code {
    background-color: transparent;
    padding: 0;
    color: inherit;
}

.message-content h1, .message-content h2, .message-content h3 {
    font-family: 'Playfair Display', Georgia, serif;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.message-content ul, .message-content ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
}

.message-content li {
    margin-bottom: 0.5rem;
}

.input-container {
    border-top: 1px solid var(--border);
    padding: 2rem;
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
}

.input-wrapper {
    max-width: 64rem;
    width: 100%;
    display: flex;
    border: 1px solid var(--border);
    border-radius: 6px;
    background-color: var(--card);
    transition: all 150ms ease-out;
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(239, 100, 39, 0.2);
}

input[type="text"] {
    flex-grow: 1;
    padding: 1rem 1.5rem;
    border: none;
    outline: none;
    font-size: 1rem;
    font-family: inherit;
    background: transparent;
    color: var(--text-color);
    min-height: 44px;
}

input[type="text"]::placeholder {
    color: var(--muted-foreground);
    opacity: 0.6;
}

.btn-primary {
    background-color: var(--accent);
    color: #FFFFFF;
    border: none;
    padding: 0 2rem;
    font-weight: 500;
    cursor: pointer;
    font-family: 'Source Sans 3', sans-serif;
    border-radius: 0 6px 6px 0;
    transition: all 200ms ease-out;
    min-height: 44px;
}

.btn-primary:hover {
    background-color: var(--accent-secondary);
}

.btn-primary:disabled {
    background-color: var(--muted-foreground);
    cursor: not-allowed;
}

.thinking {
    font-style: italic;
    color: var(--muted-foreground);
    animation: pulse 1.5s infinite;
}

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

@media (max-width: 768px) {
    body {
        flex-direction: column;
    }
    #sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        width: 80%;
        max-width: 300px;
        z-index: 500;
        transition: left 0.3s ease;
        border-right: 1px solid var(--border);
        box-shadow: 2px 0 8px rgba(0,0,0,0.1);
    }
    #sidebar.show-mobile {
        left: 0;
    }
    .sidebar-toggle {
        display: block;
        background: transparent;
        border: none;
        font-size: 1.5rem;
        cursor: pointer;
        margin-right: 1rem;
        padding: 0;
        color: var(--text-color);
    }
    .message-wrapper {
        padding: 1.5rem;
    }
    .input-container {
        padding: 1rem;
    }
}
@media (min-width: 769px) {
    .sidebar-toggle {
        display: none;
    }
}

.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    background-color: rgba(0,0,0,0.5); 
    align-items: center; 
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background-color: var(--card);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.modal-content h3 {
    margin-bottom: 1rem;
    color: var(--text-color);
}

.modal-content form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.modal-content input {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.75rem;
}

.modal-content .btn-primary {
    border-radius: 4px;
}

.error-msg {
    color: #d32f2f;
    margin-top: 1rem;
    font-size: 0.875rem;
}
