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

:root {
    --primary: #7c6a9c;
    --primary-dark: #5d4e7a;
    --primary-light: #a99bc4;
    --bg: #ebe6df;
    --bg-warm: #e5ded5;
    --surface: #ffffff;
    --text: #3d3a42;
    --text-muted: #8a858f;
    --border: #d4ccc3;
    --user-bg: linear-gradient(135deg, #7c6a9c 0%, #9b8bb8 100%);
    --user-text: #ffffff;
    --assistant-bg: #f8f5f1;
    --accent: #c4a77d;
    --shadow: rgba(124, 106, 156, 0.15);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(180deg, var(--bg) 0%, var(--bg-warm) 100%);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.7;
}

#particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
    justify-content: flex-start;
}

header {
    text-align: center;
    padding: 32px 0 24px;
    position: relative;
}

.header-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

header h1 {
    font-size: 3rem;
    font-weight: 200;
    letter-spacing: 0.2em;
    color: var(--primary);
    text-transform: uppercase;
    margin-bottom: 0;
}

.header-subtitle {
    font-size: 1rem;
    color: var(--text-muted);
    margin: 0 0 16px 0;
}

.header-avatar {
    width: 280px;
    height: 280px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 8px 32px var(--shadow);
    margin-top: 8px;
}

.header-actions {
    position: absolute;
    top: 24px;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.header-actions button {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 10px;
    border-radius: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--shadow);
}

.header-actions button:hover {
    color: var(--primary);
    border-color: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow);
}

/* Burger Menu - Hidden on desktop */
.burger-menu-btn {
    display: none;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 10px;
    border-radius: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--shadow);
}

.burger-menu-btn:hover {
    color: var(--primary);
}

/* Mobile Menu Overlay */
.mobile-menu {
    position: fixed;
    top: 0;
    right: 0;
    width: 300px;
    max-width: 85vw;
    height: 100vh;
    background: linear-gradient(180deg, var(--bg) 0%, var(--bg-warm) 100%);
    box-shadow: -8px 0 32px var(--shadow);
    z-index: 1001;
    padding: 24px;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.2s ease;
    pointer-events: auto;
}

.mobile-menu.hidden {
    transform: translateX(100%);
    pointer-events: none;
}

.mobile-menu.visible {
    transform: translateX(0);
    pointer-events: auto;
}

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.mobile-menu-close {
    align-self: flex-end;
    background: var(--surface);
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 10px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px var(--shadow);
    transition: all 0.2s ease;
}

.mobile-menu-close:hover {
    background: var(--surface);
    color: var(--primary);
    transform: scale(1.05);
}

.mobile-menu-section {
    background: var(--surface);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 12px var(--shadow);
}

.mobile-menu-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 12px;
    padding: 0 4px;
}

.mobile-plan-info {
    padding: 14px;
    background: linear-gradient(135deg, rgba(124, 106, 156, 0.1) 0%, rgba(124, 106, 156, 0.05) 100%);
    border-radius: 12px;
    margin-bottom: 12px;
    font-size: 0.9rem;
    border: 1px solid rgba(124, 106, 156, 0.1);
}

.mobile-plan-info .plan-badge {
    margin-bottom: 8px;
    display: inline-block;
}

.mobile-menu-item {
    width: 100%;
    padding: 14px 16px;
    background: transparent;
    border: none;
    text-align: left;
    font-size: 0.95rem;
    color: var(--text);
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.2s ease;
    margin-bottom: 4px;
    display: block;
}

.mobile-menu-item:hover {
    background: rgba(124, 106, 156, 0.08);
}

.mobile-menu-item:active {
    transform: scale(0.98);
}

.mobile-menu-item.hidden {
    display: none;
}

#mobile-upgrade-btn {
    color: var(--accent);
    font-weight: 500;
}

#mobile-upgrade-btn:hover {
    background: rgba(196, 167, 125, 0.1);
}

#mobile-topup-btn {
    color: var(--primary);
    font-weight: 500;
}

#mobile-topup-btn:hover {
    background: rgba(124, 106, 156, 0.1);
}

#mobile-logout-btn {
    color: var(--text-muted);
}

#mobile-logout-btn:hover {
    background: rgba(239, 68, 68, 0.08);
    color: #dc2626;
}

.mobile-menu-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2px);
    z-index: 998;
}

#settings-panel {
    background: var(--surface);
    border-radius: 20px;
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: 0 4px 24px var(--shadow);
    border: 1px solid var(--border);
}

#settings-panel h3 {
    margin-bottom: 20px;
    font-weight: 500;
    color: var(--primary);
    font-size: 1.1rem;
    letter-spacing: 0.05em;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.setting-group select,
.setting-group textarea {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: all 0.3s ease;
    background: var(--bg);
}

.setting-group select:focus,
.setting-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124, 106, 156, 0.1);
}

.setting-group textarea {
    resize: vertical;
    min-height: 140px;
    line-height: 1.6;
}

.setting-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.setting-actions button {
    padding: 12px 28px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 0.02em;
}

.setting-actions button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 106, 156, 0.3);
}

#settings-status {
    font-size: 0.85rem;
    color: var(--primary);
}

main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#chat-container {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: 24px;
    box-shadow: 0 8px 32px var(--shadow), 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    border: 2px solid var(--border);
    min-height: 500px;
}

#messages {
    flex: 1 1 auto;
    padding: 28px;
    overflow-y: auto;
    max-height: 55vh;
    min-height: 200px;
}

.message {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.4s ease;
}

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

.message.user {
    align-items: flex-end;
}

.message.assistant {
    align-items: flex-start;
    flex-direction: row;
    gap: 12px;
}

.message.assistant .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg);
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow);
}

.message.assistant .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-content {
    max-width: 85%;
    padding: 16px 20px;
    border-radius: 20px;
    font-size: 0.95rem;
    line-height: 1.7;
}

.message.user .message-content {
    background: var(--user-bg);
    color: var(--user-text);
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 12px rgba(124, 106, 156, 0.2);
}

.message.assistant .message-content {
    background: var(--assistant-bg);
    color: var(--text);
    border-bottom-left-radius: 6px;
}

/* Markdown styles */
.message.assistant .message-content h1,
.message.assistant .message-content h2,
.message.assistant .message-content h3,
.message.assistant .message-content h4 {
    margin: 16px 0 10px 0;
    font-weight: 600;
    line-height: 1.4;
    color: var(--primary-dark);
}

.message.assistant .message-content h1:first-child,
.message.assistant .message-content h2:first-child,
.message.assistant .message-content h3:first-child,
.message.assistant .message-content h4:first-child {
    margin-top: 0;
}

.message.assistant .message-content h1 { font-size: 1.3rem; }
.message.assistant .message-content h2 { font-size: 1.15rem; }
.message.assistant .message-content h3 { font-size: 1.05rem; }
.message.assistant .message-content h4 { font-size: 1rem; }

.message.assistant .message-content p {
    margin: 10px 0;
}

.message.assistant .message-content p:first-child {
    margin-top: 0;
}

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

.message.assistant .message-content strong {
    font-weight: 600;
    color: var(--primary-dark);
}

.message.assistant .message-content em {
    font-style: italic;
    color: var(--text-muted);
}

.message.assistant .message-content ul,
.message.assistant .message-content ol {
    margin: 10px 0;
    padding-left: 24px;
}

.message.assistant .message-content li {
    margin: 6px 0;
}

.message.assistant .message-content blockquote {
    border-left: 3px solid var(--accent);
    margin: 12px 0;
    padding: 8px 16px;
    background: rgba(196, 167, 125, 0.08);
    border-radius: 0 8px 8px 0;
    color: var(--text-muted);
    font-style: italic;
}

.message.assistant .message-content code {
    background: rgba(124, 106, 156, 0.08);
    padding: 3px 8px;
    border-radius: 6px;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.85em;
}

.message.assistant .message-content pre {
    background: rgba(124, 106, 156, 0.06);
    padding: 16px;
    border-radius: 12px;
    overflow-x: auto;
    margin: 12px 0;
}

.message.assistant .message-content pre code {
    background: none;
    padding: 0;
}

.message.assistant .message-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

#chat-form {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
    margin-top: auto;
}

#message-input {
    flex: 1;
    padding: 16px 20px;
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: all 0.3s ease;
    background: var(--surface);
}

#message-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124, 106, 156, 0.1);
}

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

#message-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--bg);
}

#send-btn {
    width: 52px;
    height: 52px;
    border: none;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(124, 106, 156, 0.3);
}

#send-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(124, 106, 156, 0.4);
}

#send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.save-conversation-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s;
    background: var(--bg);
    border-top: 1px solid var(--border);
}

.save-conversation-link:hover {
    background: rgba(124, 106, 156, 0.08);
    color: var(--primary);
}

.save-conversation-link.hidden {
    display: none !important;
}

#auth-section {
    margin-top: 24px;
    padding: 24px;
    background: linear-gradient(135deg, rgba(124, 106, 156, 0.05) 0%, rgba(196, 167, 125, 0.05) 100%);
    border-radius: 20px;
    border: 2px solid var(--border);
    box-shadow: 0 4px 16px var(--shadow);
}

#auth-section.hidden,
#auth-section[style*="display: none"] {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.auth-content {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

.auth-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.auth-text {
    flex: 1;
    text-align: left;
}

.auth-text h3 {
    margin: 0 0 8px 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-dark);
}

.auth-text p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-muted);
}

.auth-text strong {
    color: var(--primary-dark);
    font-weight: 600;
}

#auth-form {
    display: flex;
    gap: 12px;
}

#email-input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: all 0.3s ease;
    background: white;
}

#email-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(124, 106, 156, 0.1);
}

#auth-form button {
    padding: 14px 32px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(124, 106, 156, 0.3);
}

#auth-form button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(124, 106, 156, 0.4);
}

#auth-message {
    margin-top: 12px;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
    background: rgba(124, 106, 156, 0.1);
    color: var(--primary-dark);
    font-weight: 500;
}

footer {
    text-align: center;
    padding: 20px;
    margin-top: auto;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.footer-links {
    margin-top: 8px;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary);
}

/* Legal Pages */
.legal-page {
    max-width: 800px;
}

.legal-page header {
    padding: 32px 0 24px;
}

.logo-link {
    text-decoration: none;
}

.logo-link h1 {
    transition: opacity 0.2s;
}

.logo-link:hover h1 {
    opacity: 0.8;
}

.legal-content {
    background: var(--surface);
    border-radius: 24px;
    padding: 48px;
    box-shadow: 0 8px 32px var(--shadow);
    border: 2px solid var(--border);
}

.legal-content h2 {
    color: var(--primary);
    font-size: 2rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.legal-content .last-updated {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 32px;
}

.legal-content section {
    margin-bottom: 32px;
}

.legal-content section:last-child {
    margin-bottom: 0;
}

.legal-content h3 {
    color: var(--primary-dark);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.legal-content p {
    color: var(--text);
    line-height: 1.8;
    margin-bottom: 12px;
}

.legal-content ul {
    padding-left: 24px;
    margin: 12px 0;
}

.legal-content li {
    color: var(--text);
    line-height: 1.8;
    margin-bottom: 8px;
}

.legal-content a {
    color: var(--primary);
    text-decoration: none;
}

.legal-content a:hover {
    text-decoration: underline;
}

@media (max-width: 600px) {
    .legal-content {
        padding: 28px 20px;
    }
    
    .legal-content h2 {
        font-size: 1.5rem;
    }
}

.hidden {
    display: none !important;
}

#loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(248, 246, 243, 0.9);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Streaming cursor effect */
#streaming-message .message-content::after {
    content: '▋';
    animation: blink 1s infinite;
    color: var(--primary);
    margin-left: 2px;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 16px 20px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--primary-light);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Scrollbar styling */
#messages::-webkit-scrollbar {
    width: 6px;
}

#messages::-webkit-scrollbar-track {
    background: transparent;
}

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

#messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

@media (max-width: 600px) {
    .container {
        padding: 16px;
    }
    
    header {
        padding: 24px 0 16px;
    }
    
    header h1 {
        font-size: 1.75rem;
    }
    
    .header-subtitle {
        font-size: 0.9rem;
    }
    
    .header-avatar {
        width: 140px;
        height: 140px;
    }
    
    .header-actions {
        top: 16px;
    }
    
    /* Show burger menu, hide desktop buttons */
    .burger-menu-btn {
        display: flex;
    }
    
    .account-dropdown,
    #conversations-btn,
    #new-chat-btn {
        display: none !important;
    }
    
    .auth-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .auth-text {
        text-align: center;
    }
    
    #auth-form {
        flex-direction: column;
    }
    
    #auth-form button {
        width: 100%;
    }
    
    .message-content {
        max-width: 90%;
    }
    
    #messages {
        padding: 20px;
    }
    
    #chat-form {
        padding: 16px;
    }
}

/* Conversation Selector Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
}

#close-modal-btn {
    color: var(--text-muted);
    transition: all 0.2s;
}

#close-modal-btn:hover {
    background: rgba(0, 0, 0, 0.05) !important;
    color: var(--primary-dark);
}

.modal-content h2 {
    margin: 0 0 8px 0;
    color: var(--primary);
    font-size: 28px;
}

#conversations-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 8px;
}

.conversation-item {
    padding: 16px 20px;
    border: 2px solid var(--border);
    border-radius: 12px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.conversation-item:hover {
    border-color: var(--primary);
    background: rgba(124, 106, 156, 0.05);
    transform: translateY(-2px);
}

.conversation-content {
    flex: 1;
    cursor: pointer;
}

.conversation-title {
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 4px;
    font-size: 16px;
}

.conversation-preview {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 8px;
}

.conversation-meta {
    color: var(--text-muted);
    font-size: 12px;
}

.delete-conversation-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.delete-conversation-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

#new-conversation-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 16px 24px;
    font-weight: 600;
    font-size: 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(124, 106, 156, 0.3);
    position: relative;
    overflow: hidden;
}

#new-conversation-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(124, 106, 156, 0.4);
}

#new-conversation-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(124, 106, 156, 0.3);
}

#new-conversation-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

#new-conversation-btn:hover::before {
    left: 100%;
}

/* Account Dropdown */
.account-dropdown {
    position: relative;
}

.account-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 10px;
    border-radius: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--shadow);
}

.account-btn:hover {
    color: var(--primary);
    border-color: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow);
}

.account-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 8px 32px var(--shadow);
    min-width: 280px;
    z-index: 100;
    animation: fadeIn 0.2s ease;
}

.account-menu-header {
    padding: 16px 20px;
    font-size: 0.9rem;
    color: var(--text-muted);
    word-break: break-all;
}

.account-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 0;
}

.account-plan-info {
    padding: 16px 20px;
}

.plan-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.plan-badge.free {
    background: var(--bg);
    color: var(--text-muted);
}

.plan-badge.paid {
    background: linear-gradient(135deg, var(--accent) 0%, #d4b896 100%);
    color: white;
}

.usage-info {
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 8px;
}

.usage-bar-container {
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
}

.usage-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.usage-bar.warning {
    background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
}

.usage-bar.danger {
    background: linear-gradient(90deg, #ef4444 0%, #f87171 100%);
}

.renewal-info {
    margin-top: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.account-menu-btn {
    width: 100%;
    padding: 14px 20px;
    background: none;
    border: none;
    outline: none;
    box-shadow: none;
    text-align: left;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
}

.account-menu-btn:hover {
    background: var(--bg);
}

.account-menu-btn:last-child {
    border-radius: 0 0 16px 16px;
}

.account-menu-btn.upgrade-btn {
    color: var(--accent);
    font-weight: 500;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

.account-menu-btn.upgrade-btn:hover {
    background: rgba(196, 167, 125, 0.1);
}

.account-menu-btn.topup-btn {
    color: var(--primary);
    font-weight: 500;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

.account-menu-btn.topup-btn:hover {
    background: rgba(124, 106, 156, 0.1);
}

.account-menu-btn .btn-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.account-menu-btn .btn-subtext {
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.7;
}

.mobile-btn-subtext {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.65;
    margin-top: 2px;
}

.account-menu-btn.logout-btn {
    color: var(--text-muted);
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

.account-menu-btn.logout-btn:hover {
    background: rgba(239, 68, 68, 0.08);
    color: #dc2626;
}

/* Paywall Modal */
.paywall-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    animation: fadeIn 0.2s ease;
}

.paywall-content {
    background: white;
    border-radius: 24px;
    padding: 48px;
    max-width: 480px;
    width: 90%;
    text-align: center;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
    position: relative;
}

.paywall-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.paywall-close:hover {
    background: var(--bg);
    color: var(--text);
}

.paywall-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    color: white;
}

.paywall-content h2 {
    font-size: 1.75rem;
    color: var(--primary-dark);
    margin-bottom: 12px;
    font-weight: 600;
}

.paywall-content p {
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 24px;
}

.paywall-features {
    text-align: left;
    margin: 24px 0;
    padding: 20px;
    background: var(--bg);
    border-radius: 16px;
}

.paywall-features li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    color: var(--text);
    font-size: 0.95rem;
}

.paywall-features li svg {
    color: var(--primary);
    flex-shrink: 0;
}

.paywall-price {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin: 8px 0;
}

.paywall-price span {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-muted);
}

.paywall-upgrade-btn {
    width: 100%;
    padding: 18px 32px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 24px rgba(124, 106, 156, 0.4);
}

.paywall-upgrade-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(124, 106, 156, 0.5);
}

.paywall-renewal-info {
    background: rgba(124, 106, 156, 0.1);
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
}

.paywall-renewal-info p {
    margin: 0;
    color: var(--primary-dark);
    font-weight: 500;
}

.paywall-portal-link {
    display: inline-block;
    margin-top: 12px;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
}

.paywall-portal-link:hover {
    text-decoration: underline;
}

@media (max-width: 600px) {
    .account-menu {
        right: -60px;
        min-width: 260px;
    }
    
    .paywall-content {
        padding: 32px 24px;
    }
    
    .paywall-content h2 {
        font-size: 1.5rem;
    }
    
    .paywall-price {
        font-size: 2rem;
    }
}

/* Messages Remaining Notice */
.messages-remaining-notice {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #fff9e6 0%, #fff3cc 100%);
    border: 1px solid #e6d9a8;
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    animation: slideDown 0.3s ease;
    transition: opacity 0.3s, transform 0.3s;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.messages-remaining-notice .notice-content {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #8b6914;
    font-size: 0.9rem;
}

.messages-remaining-notice .notice-content svg {
    flex-shrink: 0;
    color: #c99700;
}

.messages-remaining-notice .notice-content a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    margin-left: 4px;
}

.messages-remaining-notice .notice-content a:hover {
    text-decoration: underline;
}

.messages-remaining-notice .notice-close {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #b89b3e;
    border-radius: 6px;
    transition: background 0.2s;
}

.messages-remaining-notice .notice-close:hover {
    background: rgba(139, 105, 20, 0.1);
}

/* Sign-up prompt icon styling */
.signup-icon {
    background: linear-gradient(135deg, rgba(124, 106, 156, 0.15) 0%, rgba(100, 80, 140, 0.2) 100%);
}

@media (max-width: 600px) {
    .messages-remaining-notice {
        left: 16px;
        right: 16px;
        transform: none;
        width: auto;
    }
    
    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* Paywall Options (subscription vs one-off) */
.paywall-options {
    display: flex;
    gap: 16px;
    margin-top: 24px;
}

.paywall-option {
    flex: 1;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(124, 106, 156, 0.2);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    position: relative;
}

.paywall-option-primary {
    border: 2px solid var(--primary);
    background: rgba(124, 106, 156, 0.05);
    padding-top: 32px; /* Extra space for badge */
}

.paywall-option-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.paywall-option h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 8px 0;
}

.paywall-option .paywall-price {
    font-size: 1.5rem;
    margin: 8px 0 12px 0;
}

.paywall-option .paywall-price-small {
    font-size: 1.2rem;
}

.paywall-option .paywall-features {
    text-align: left;
    margin: 12px 0;
    padding: 0;
}

.paywall-option .paywall-features li {
    font-size: 0.85rem;
    padding: 4px 0;
}

.paywall-topup-btn {
    width: 100%;
    padding: 12px 20px;
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.paywall-topup-btn:hover {
    background: var(--primary);
    color: white;
}

.paywall-topup-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Top-up success notice */
.topup-success-notice {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border: 1px solid #a5d6a7;
    border-radius: 12px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    animation: slideDown 0.3s ease;
    transition: opacity 0.3s, transform 0.3s;
}

.topup-success-notice .notice-content {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #2e7d32;
    font-weight: 500;
}

.topup-success-notice svg {
    color: #43a047;
}

@media (max-width: 600px) {
    .paywall-options {
        flex-direction: column;
    }
    
    .paywall-option-badge {
        font-size: 0.65rem;
    }
    
    .topup-success-notice {
        left: 16px;
        right: 16px;
        transform: none;
    }
}
