/* The Underground Man - A dark, literary aesthetic */

:root {
    --bg-deep: #0a0908;
    --bg-surface: #1a1714;
    --bg-elevated: #2a2520;
    --text-primary: #d4c5b0;
    --text-muted: #8a7f70;
    --text-dim: #5a5248;
    --accent: #c4a77d;
    --accent-dim: #8a7355;
    --border: #3a352e;
    --shadow: rgba(0, 0, 0, 0.5);
}

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

html {
    font-size: 18px;
}

body {
    font-family: 'EB Garamond', Georgia, serif;
    background-color: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.7;
    
    /* Subtle texture overlay */
    background-image: 
        radial-gradient(ellipse at 50% 0%, rgba(74, 60, 40, 0.15) 0%, transparent 60%),
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%' height='100%' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-blend-mode: normal, overlay;
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    text-align: center;
    padding: 2rem 0 3rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

.header h1 {
    font-size: 2.4rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 20px rgba(196, 167, 125, 0.2);
}

.subtitle {
    font-family: 'Bitter', serif;
    font-size: 0.85rem;
    font-weight: 300;
    color: var(--text-muted);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
}

.epigraph {
    font-style: italic;
    color: var(--text-dim);
    font-size: 1rem;
    max-width: 400px;
    margin: 0 auto;
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Messages */
.message {
    animation: fadeIn 0.4s ease-out;
}

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

.message-content {
    padding: 1.25rem 1.5rem;
    border-radius: 3px;
    position: relative;
}

.message.assistant .message-content {
    background: var(--bg-surface);
    border-left: 2px solid var(--accent-dim);
    box-shadow: 0 4px 20px var(--shadow);
}

.message.user .message-content {
    background: var(--bg-elevated);
    border-left: 2px solid var(--text-dim);
    margin-left: 2rem;
}

.message-content p {
    margin-bottom: 1rem;
}

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

/* Labels */
.message::before {
    display: block;
    font-family: 'Bitter', serif;
    font-size: 0.7rem;
    font-weight: 300;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}

.message.assistant::before {
    content: "The Underground Man";
}

.message.user::before {
    content: "You";
    margin-left: 2rem;
}

/* Input Form */
.chat-input-form {
    display: flex;
    gap: 1rem;
    padding: 1.5rem 0;
    border-top: 1px solid var(--border);
    margin-top: 1rem;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1rem 1.25rem;
    color: var(--text-primary);
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 1rem;
    line-height: 1.6;
    resize: none;
    min-height: 56px;
    max-height: 200px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-input:focus {
    outline: none;
    border-color: var(--accent-dim);
    box-shadow: 0 0 0 3px rgba(196, 167, 125, 0.1);
}

.chat-input::placeholder {
    color: var(--text-dim);
    font-style: italic;
}

.send-button {
    background: var(--bg-elevated);
    border: 1px solid var(--accent-dim);
    color: var(--accent);
    padding: 1rem 1.75rem;
    font-family: 'Bitter', serif;
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 100px;
    height: 56px;
}

.send-button:hover:not(:disabled) {
    background: var(--accent-dim);
    color: var(--bg-deep);
}

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

/* Loading Spinner */
.loading-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--text-dim);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.hidden {
    display: none;
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem 0 1rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

.footer p {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.footer em {
    color: var(--text-muted);
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-deep);
}

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

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

/* Responsive */
@media (max-width: 600px) {
    html {
        font-size: 16px;
    }
    
    .container {
        padding: 1rem;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
    
    .message.user .message-content {
        margin-left: 1rem;
    }
    
    .message.user::before {
        margin-left: 1rem;
    }
    
    .chat-input-form {
        flex-direction: column;
    }
    
    .send-button {
        width: 100%;
    }
}
