/* ===== CSS Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --eliza-bubble: #1e293b;
    --user-bubble: #6366f1;
    --border: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-lg: 16px;
}

html {
    height: 100%;
    height: -webkit-fill-available;
    overflow: hidden;
}

body {
    height: 100%;
    height: -webkit-fill-available;
    overflow: hidden;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* ===== App Container ===== */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    height: -webkit-fill-available;
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg);
}

/* ===== Setup Screen ===== */
.setup-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 20px;
}

.setup-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 60px var(--shadow);
    border: 1px solid var(--border);
}

.setup-logo {
    text-align: center;
    margin-bottom: 36px;
}

.setup-logo h1 {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 6px;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.setup-subtitle {
    color: var(--text-muted);
    font-size: 1.05rem;
    font-weight: 300;
}

.setup-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.setup-lang {
    justify-content: center;
}

.language-selector {
    display: flex;
    gap: 10px;
}

.lang-btn {
    padding: 10px 20px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.lang-btn:hover {
    border-color: var(--primary-light);
    color: var(--text);
}

.lang-btn.active {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

.name-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.name-input-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.name-input {
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s ease;
}

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

.name-input::placeholder {
    color: var(--text-muted);
}

.start-btn {
    padding: 14px;
    border: none;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
}

.start-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

.start-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Header ===== */

.header-content {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.header-content h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 4px;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.app-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.github-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: color 0.2s ease;
    flex-shrink: 0;
}

.github-link:hover {
    color: var(--text);
}

.github-link svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.end-session-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-right: 8px;
}

.end-session-btn:hover {
    border-color: var(--primary-light);
    color: var(--text);
    background: rgba(99, 102, 241, 0.1);
}

.setup-footer {
    text-align: center;
    margin-top: 12px;
}

.setup-footer a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: color 0.2s ease;
}

.setup-footer a:hover {
    color: var(--text);
}

.setup-footer svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* ===== Chat Container ===== */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ===== Messages ===== */
.message {
    display: flex;
    animation: fadeIn 0.3s ease;
}

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

.eliza-message {
    justify-content: flex-start;
}

.user-message {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: var(--radius);
    line-height: 1.5;
}

.eliza-message .message-bubble {
    background: var(--eliza-bubble);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.user-message .message-bubble {
    background: var(--user-bubble);
    border-bottom-right-radius: 4px;
}

.sender-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-light);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.message-bubble p {
    margin: 0;
    font-size: 0.95rem;
}

/* ===== Input ===== */
.input-container {
    padding: 16px 24px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    gap: 10px;
}

.message-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s ease;
}

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

.message-input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    background: var(--primary);
    color: white;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.send-btn:hover {
    background: var(--primary-dark);
}

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

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

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

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

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .setup-card {
        padding: 32px 24px;
    }

    .setup-logo h1 {
        font-size: 2.2rem;
    }

    .message-bubble {
        max-width: 85%;
    }
}

