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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: #f5f4ef;
    color: #2d2d2d;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* ========== AUTH SCREEN ========== */
.auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f5f4ef;
    padding: 20px;
}

.auth-container {
    width: 100%;
    max-width: 400px;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: #2d2d2d;
    margin-bottom: 8px;
}

.auth-header p {
    font-size: 15px;
    color: #8a8780;
    line-height: 1.5;
}

.auth-form input {
    width: 100%;
    padding: 14px 16px;
    background: #ffffff;
    border: 1px solid #d9d6cc;
    border-radius: 10px;
    color: #2d2d2d;
    font-size: 15px;
    font-family: inherit;
    margin-bottom: 12px;
    transition: border-color 0.2s;
}

.auth-form input:focus {
    outline: none;
    border-color: #7a9e7e;
    box-shadow: 0 0 0 2px rgba(122, 158, 126, 0.15);
}

.auth-form input::placeholder {
    color: #a8a5a0;
}

.auth-btn {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.primary-btn {
    background: #7a9e7e;
    color: white;
}

.primary-btn:hover {
    background: #668a6a;
}

.google-btn {
    background: #ffffff;
    color: #2d2d2d;
    border: 1px solid #d9d6cc;
}

.google-btn:hover {
    background: #f5f4ef;
    border-color: #b8b5ad;
}

.apple-btn {
    background: #000000;
    color: #ffffff;
}

.apple-btn:hover {
    background: #222222;
}

.phone-btn {
    background: #ffffff;
    color: #2d2d2d;
    border: 1px solid #d9d6cc;
}

.phone-btn:hover {
    background: #f5f4ef;
    border-color: #b8b5ad;
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #d9d6cc;
}

.auth-divider span {
    padding: 0 16px;
    color: #a8a5a0;
    font-size: 13px;
}

.auth-footer-links {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: #8a8780;
}

.auth-footer-links a {
    color: #7a9e7e;
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
}

.auth-footer-links a:hover {
    text-decoration: underline;
}

.auth-footer-sep {
    margin: 0 8px;
    color: #d9d6cc;
}

.auth-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 14px;
    margin-bottom: 16px;
    text-align: center;
}

.phone-sent-msg,
.reset-msg {
    color: #8a8780;
    font-size: 14px;
    text-align: center;
    margin-bottom: 16px;
    line-height: 1.5;
}

/* Guest option - primary CTA at top */
.guest-option-top {
    margin-bottom: 8px;
}

.guest-btn-primary {
    background: #7a9e7e;
    color: white;
    font-weight: 600;
    font-size: 16px;
    padding: 16px 20px;
    border-radius: 12px;
}

.guest-btn-primary:hover {
    background: #668a6a;
}

/* Guest label in sidebar */
.guest-label {
    color: #a8a5a0;
    font-style: italic;
}

/* Create Account button in sidebar (for guests) */
.create-account-btn {
    background: #7a9e7e;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}

.create-account-btn:hover {
    background: #668a6a;
}

/* Signup prompt overlay (for guests who hit limit) */
.signup-prompt {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.signup-prompt-content {
    background: #f5f4ef;
    border-radius: 16px;
    padding: 40px 32px;
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.signup-prompt-content h2 {
    font-size: 20px;
    font-weight: 600;
    color: #2d2d2d;
    margin-bottom: 12px;
    line-height: 1.4;
}

.signup-prompt-content p {
    font-size: 14px;
    color: #8a8780;
    margin-bottom: 24px;
    line-height: 1.6;
}

.signup-prompt-content .auth-btn {
    margin-bottom: 10px;
}

.dismiss-link {
    display: inline-block;
    margin-top: 12px;
    font-size: 13px;
    color: #a8a5a0;
    cursor: pointer;
    text-decoration: none;
}

.dismiss-link:hover {
    color: #8a8780;
    text-decoration: underline;
}

/* ========== SIDEBAR FOOTER (User Info) ========== */
.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid #d9d6cc;
    background: #ebe9e1;
}

.user-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-name {
    font-size: 13px;
    color: #2d2d2d;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 150px;
}

.signout-btn {
    background: transparent;
    border: 1px solid #d9d6cc;
    color: #8a8780;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.signout-btn:hover {
    background: #d9534f;
    color: white;
    border-color: #d9534f;
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: 280px;
    background: #ebe9e1;
    border-right: 1px solid #d9d6cc;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #d9d6cc;
}

.sidebar-header h1 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #2d2d2d;
}

.new-chat-btn {
    width: 100%;
    padding: 10px 16px;
    background: #7a9e7e;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.new-chat-btn:hover {
    background: #668a6a;
}

/* ========== CONVERSATIONS LIST ========== */
.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.conversation-item {
    padding: 12px 14px;
    margin-bottom: 6px;
    background: #f5f4ef;
    border: 1px solid #d9d6cc;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.conversation-item:hover {
    background: #ffffff;
    border-color: #7a9e7e;
}

.conversation-item.active {
    background: #ffffff;
    border-color: #7a9e7e;
}

.conversation-title {
    font-size: 14px;
    color: #2d2d2d;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 50px;
}

.conversation-date {
    font-size: 12px;
    color: #8a8780;
}

.delete-conversation {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: #d9534f;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.conversation-item:hover .delete-conversation {
    opacity: 1;
}

.delete-conversation:hover {
    background: #c9302c;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f5f4ef;
    position: relative;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 30px 20px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

/* ========== WELCOME MESSAGE ========== */
.welcome-message {
    text-align: center;
    padding: 80px 20px;
    color: #8a8780;
}

.welcome-message h2 {
    font-size: 22px;
    font-weight: 600;
    color: #2d2d2d;
    margin-bottom: 12px;
}

.welcome-message p {
    font-size: 15px;
    line-height: 1.6;
    max-width: 500px;
    margin: 0 auto;
}

.welcome-tagline {
    margin-top: 20px !important;
    font-weight: 600;
    color: #7a9e7e;
    letter-spacing: 0.5px;
}

/* ========== MESSAGES ========== */
.message {
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease;
}

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

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

.user-message .message-content {
    background: #7a9e7e;
    color: #ffffff;
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 80%;
    border: none;
    font-size: 16px;
    line-height: 1.6;
}

.assistant-message .message-content {
    background: transparent;
    color: #2d2d2d;
    padding: 0;
    max-width: 100%;
    line-height: 1.7;
    font-size: 16px;
}

/* ========== LOADING HEART ANIMATION ========== */
.loading-heart {
    display: flex;
    align-items: center;
    padding: 8px 0 !important;
    position: relative;
}

.loading-heart .heart-glow {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(122,158,126,0.25) 0%, transparent 70%);
    animation: heartGlow 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    pointer-events: none;
}

.loading-heart img {
    animation: heartbeat 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    filter: drop-shadow(0 1px 3px rgba(122,158,126,0.3));
    position: relative;
}

@keyframes heartbeat {
    0% { transform: scale(1); }
    8% { transform: scale(1.18); }
    16% { transform: scale(0.97); }
    24% { transform: scale(1.12); }
    36% { transform: scale(1); }
    100% { transform: scale(1); }
}

@keyframes heartGlow {
    0% { transform: scale(0.8); opacity: 0; }
    8% { transform: scale(1.3); opacity: 1; }
    16% { transform: scale(0.9); opacity: 0.4; }
    24% { transform: scale(1.15); opacity: 0.7; }
    36% { transform: scale(1); opacity: 0.3; }
    60% { opacity: 0; }
    100% { transform: scale(0.8); opacity: 0; }
}

/* ========== SCROLL DOWN ARROW ========== */
.scroll-down-arrow {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    background: white;
    border: 1px solid #d9d6cc;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 50;
    animation: bounceArrow 2s ease-in-out infinite;
    transition: opacity 0.3s;
}

.scroll-down-arrow:hover {
    background: #f5f4ef;
    border-color: #7a9e7e;
}

@keyframes bounceArrow {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(4px); }
}

.message-content p {
    margin-bottom: 12px;
}

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

.message-content strong {
    color: #668a6a;
    font-weight: 600;
}

/* ========== INPUT AREA ========== */
.input-container {
    padding: 12px 20px;
    border-top: 1px solid #d9d6cc;
    background: #f5f4ef;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #ffffff;
    border: 1px solid #d9d6cc;
    border-radius: 24px;
    padding: 8px 8px 8px 16px;
    transition: border-color 0.2s;
}

.input-row:focus-within {
    border-color: #7a9e7e;
    box-shadow: 0 0 0 2px rgba(122, 158, 126, 0.15);
}

#user-input {
    flex: 1;
    min-height: 24px;
    max-height: 150px;
    padding: 4px 0;
    background: transparent;
    border: none;
    color: #2d2d2d;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    line-height: 1.5;
    overflow-y: auto;
}

#user-input:focus {
    outline: none;
}

#user-input::placeholder {
    color: #a8a5a0;
}

.send-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0;
    background: #7a9e7e;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover {
    background: #668a6a;
}

.send-btn:active {
    transform: scale(0.95);
}

/* ========== SCROLLBAR ========== */
.conversations-list::-webkit-scrollbar,
.chat-container::-webkit-scrollbar {
    width: 8px;
}

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

.conversations-list::-webkit-scrollbar-thumb,
.chat-container::-webkit-scrollbar-thumb {
    background: #d9d6cc;
    border-radius: 4px;
}

.conversations-list::-webkit-scrollbar-thumb:hover,
.chat-container::-webkit-scrollbar-thumb:hover {
    background: #b8b5ad;
}

/* ========== MOBILE HEADER BAR ========== */
.mobile-header {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #f5f4ef;
    border-bottom: 1px solid #d9d6cc;
    position: relative;
    z-index: 1000;
    flex-shrink: 0;
}

.mobile-header .mobile-menu-btn {
    display: flex;
    position: static;
    background: #7a9e7e;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.mobile-header .mobile-title {
    font-size: 16px;
    font-weight: 600;
    color: #2d2d2d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    body {
        height: 100vh;
        height: -webkit-fill-available;
        overflow: hidden;
    }

    .mobile-header {
        display: flex;
    }

    /* Hide the old standalone menu button */
    #app-screen > .mobile-menu-btn {
        display: none !important;
    }

    .app-container {
        height: 100vh;
        height: -webkit-fill-available;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        height: -webkit-fill-available;
        z-index: 999;
        transition: left 0.3s ease;
        width: 280px;
    }

    .sidebar.open {
        left: 0;
    }

    .main-content {
        width: 100%;
        height: 100vh;
        height: -webkit-fill-available;
        display: flex;
        flex-direction: column;
    }

    .chat-container {
        flex: 1;
        padding: 20px 15px 10px 15px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .input-container {
        flex-shrink: 0;
        padding: 8px 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        background: #f5f4ef;
        border-top: 1px solid #d9d6cc;
        position: relative;
        z-index: 100;
    }

    #user-input {
        font-size: 16px; /* Prevents iOS zoom */
    }

    .send-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }

    .welcome-message {
        padding: 40px 15px;
    }

    .welcome-message h2 {
        font-size: 18px;
    }

    /* Show delete button on mobile (no hover) */
    .delete-conversation {
        opacity: 0.7;
    }

    /* Auth screen mobile */
    .auth-screen {
        padding: 20px 16px;
        align-items: flex-start;
        padding-top: 60px;
    }

    .auth-header h1 {
        font-size: 24px;
    }

    .auth-form input,
    .auth-btn {
        font-size: 16px; /* Prevents iOS zoom on focus */
    }
}
