/* Inter Variable Font - Self-hosted for better performance and consistency */
@font-face {
    font-family: 'Inter';
    src: url('/fonts/Inter-Variable.woff2') format('woff2-variations');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* iOS Safari: ensure background fills safe areas (notch, home indicator) */
html {
    background: #212121;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 400; /* Use normal weight by default */
    /* font-synthesis: none; REMOVED - was preventing bold when custom fonts fail to load */
    /* Industry standard (ChatGPT, Claude): Allow synthesis as fallback when custom fonts unavailable */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: #212121;
    min-height: 100vh;
    color: #ECECF1;
    overflow: hidden;
}

/* =============================================================================
   LOADING SKELETON (Auth Check State - Phase 1)
   ============================================================================= */

/* Overlay that covers entire viewport during loading */
.loading-skeleton-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #212121;
    z-index: 9999;
    display: none; /* Hidden by default */
}

/* Removed: Old generic rule that showed BOTH skeletons
   Now using specific rules below: app-loading-anonymous and app-loading-authenticated */

/* Skeleton container (mirrors actual app layout) */
.skeleton-container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Skeleton header */
.skeleton-header {
    height: 60px;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #2d2d2d;
}

.skeleton-logo {
    width: 120px;
    height: 30px;
    background: linear-gradient(90deg, #2d2d2d 25%, #3d3d3d 50%, #2d2d2d 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

.skeleton-auth-buttons {
    display: flex;
    gap: 10px;
}

.skeleton-button {
    width: 80px;
    height: 36px;
    background: linear-gradient(90deg, #2d2d2d 25%, #3d3d3d 50%, #2d2d2d 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

/* Skeleton main content */
.skeleton-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 40px;
}

.skeleton-welcome-text {
    width: 300px;
    height: 40px;
    background: linear-gradient(90deg, #2d2d2d 25%, #3d3d3d 50%, #2d2d2d 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

.skeleton-input-box {
    width: 600px;
    max-width: 90%;
    height: 60px;
    background: linear-gradient(90deg, #2d2d2d 25%, #3d3d3d 50%, #2d2d2d 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 24px;
}

/* Shimmer animation */
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Hide container content when loading */
.container.loading-skeleton {
    opacity: 0;
}

body.app-loading .container {
    opacity: 0;
}

/* Authenticated mode styling */
.container.authenticated-mode .landing-page {
    display: none !important;
}

/* Mobile skeleton adjustments */
@media (max-width: 768px) {
    .skeleton-input-box {
        width: 90%;
        height: 50px;
    }

    .skeleton-welcome-text {
        width: 250px;
        height: 30px;
    }

    /* Position skeleton input to match actual sticky input position */
    .skeleton-input-container {
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        margin-bottom: 0; /* No margin - go to edge */
        padding: 16px 16px env(safe-area-inset-bottom, 8px) 16px; /* Safe area in padding */
        background: #212121;
    }

    .skeleton-chat-input {
        margin: 0 auto;
    }
}

/* Show appropriate skeleton based on body class */
body.app-loading-anonymous .anonymous-skeleton {
    display: flex !important;
}

body.app-loading-authenticated .authenticated-skeleton {
    display: flex !important;
}

/* =============================================================================
   Authenticated Skeleton (Sidebar + Chat Layout)
   ============================================================================= */

/* Authenticated skeleton layout - matches real app grid */
.skeleton-app-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    width: 100%;
    height: 100vh;
    background: #212121;
}

/* Skeleton Sidebar */
.skeleton-sidebar {
    background: #171717;
    border-right: 1px solid #2d2d2d;
    display: flex;
    flex-direction: column;
    padding: 12px;
}

/* Sidebar Header (New Chat button) */
.skeleton-sidebar-header {
    margin-bottom: 16px;
}

.skeleton-new-chat-button {
    width: 100%;
    height: 44px;
    background: linear-gradient(90deg, #2d2d2d 25%, #3d3d3d 50%, #2d2d2d 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

/* Conversation List */
.skeleton-conversations {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
}

.skeleton-conversation-item {
    width: 100%;
    height: 44px;
    background: linear-gradient(90deg, #1f1f1f 25%, #2d2d2d 50%, #1f1f1f 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

/* User Section at Bottom */
.skeleton-user-section {
    margin-top: 12px;
    padding: 12px;
    border-top: 1px solid #2d2d2d;
    display: flex;
    align-items: center;
    gap: 12px;
}

.skeleton-user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(90deg, #2d2d2d 25%, #3d3d3d 50%, #2d2d2d 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-user-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.skeleton-user-name {
    width: 80px;
    height: 14px;
    background: linear-gradient(90deg, #2d2d2d 25%, #3d3d3d 50%, #2d2d2d 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

.skeleton-user-email {
    width: 120px;
    height: 12px;
    background: linear-gradient(90deg, #2d2d2d 25%, #3d3d3d 50%, #2d2d2d 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

/* Skeleton Main Chat Area */
.skeleton-main-chat {
    display: flex;
    flex-direction: column;
    background: #212121;
}

/* Chat Header */
.skeleton-chat-header {
    height: 60px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #2d2d2d;
}

.skeleton-chat-title {
    width: 200px;
    height: 24px;
    background: linear-gradient(90deg, #2d2d2d 25%, #3d3d3d 50%, #2d2d2d 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 6px;
}

/* Empty Chat Messages Area */
.skeleton-chat-messages {
    flex: 1;
    background: #212121;
}

/* Input Container at Bottom */
.skeleton-input-container {
    padding: 24px;
    display: flex;
    justify-content: center;
}

.skeleton-chat-input {
    width: 100%;
    max-width: 800px;
    height: 60px;
    background: linear-gradient(90deg, #2d2d2d 25%, #3d3d3d 50%, #2d2d2d 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 24px;
}

/* Mobile adjustments for authenticated skeleton */
@media (max-width: 768px) {
    .skeleton-app-layout {
        grid-template-columns: 1fr; /* Full width on mobile */
    }

    .skeleton-sidebar {
        display: none; /* Hide sidebar skeleton on mobile */
    }

    .skeleton-chat-input {
        height: 50px;
        border-radius: 20px;
    }
}

/* =============================================================================
   End Loading Skeleton
   ============================================================================= */

/* App Layout - CSS Grid */
.app-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    height: 100vh;
    overflow: hidden;
    transition: grid-template-columns 0.3s ease;
}

.app-layout.sidebar-collapsed {
    grid-template-columns: 50px 1fr;
}

/* Hide sidebar for anonymous users - adjust grid to single column */
.app-layout.no-sidebar {
    grid-template-columns: 1fr;
}

.app-layout.no-sidebar .sidebar {
    display: none;
}

/* Sidebar Styles */
.sidebar {
    background: #181818;
    border-right: 1px solid #2d2d2d;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.3s ease;
    position: relative;
}

/* ── Collapsed sidebar ─────────────────────────────────────── */

/* Hide chats section — no invisible DOM elements eating layout */
.app-layout.sidebar-collapsed .sidebar-chats-label,
.app-layout.sidebar-collapsed .conversations-list {
    display: none;
}

/* Hide nav item text labels; icons remain visible */
.app-layout.sidebar-collapsed .sidebar-nav-item span {
    display: none;
}

/* Header padding when collapsed */
.app-layout.sidebar-collapsed .sidebar-header {
    padding: 12px 7px 0 7px;
}

/* Footer: pushed to bottom; no separator line; no hover highlight */
.app-layout.sidebar-collapsed .sidebar-footer {
    margin-top: auto;
    border-top: none;
}

.app-layout.sidebar-collapsed .user-profile.clickable:hover {
    background: transparent;
}

.app-layout.sidebar-collapsed .settings-icon {
    display: none;
}

/* Fade text items out — sidebar overflow:hidden clips them spatially,
   opacity handles the visual fade so there's no pop on expand */
.app-layout.sidebar-collapsed .user-details,
.app-layout.sidebar-collapsed .upgrade-btn-sidebar {
    opacity: 0;
}

.user-details,
.upgrade-btn-sidebar {
    transition: opacity 0.2s ease;
}

.collapsed-avatar {
    display: none;
}

.sidebar-header {
    padding: 12px 12px 0 12px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-shrink: 0;
    transition: padding 0.3s ease;
}

.sidebar-toggle-btn {
    background: transparent;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #8e8e8e;
    transition: all 0.2s ease;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}


.sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #ECECF1;
}

/* Hide on mobile (mobile uses overlay instead) */
@media (max-width: 768px) {
    .sidebar-toggle-btn {
        display: none;
    }
}

/* Sidebar nav items */
.sidebar-nav {
    padding: 4px 8px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex-shrink: 0;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #ECECF1;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s ease;
    text-decoration: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-nav-item svg {
    flex-shrink: 0;
    color: #b4b4b4;
}

/* "Your chats" label */
.sidebar-chats-label {
    padding: 16px 16px 8px 16px;
    font-size: 0.75rem;
    color: #8e8e8e;
    font-weight: 500;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    color: #ECECF1;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px;
    background: #181818;
    min-height: 0;
}

.empty-conversations {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.conversation-item {
    padding: 8px 8px;
    margin: 1px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.conversation-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.conversation-item.active {
    background: rgba(255, 255, 255, 0.05);
}

.conversation-title {
    font-weight: 400;
    font-size: 0.875rem;
    color: #ECECF1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-content {
    flex: 1;
    min-width: 0;
}

.conversation-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    transition: opacity 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
    .conversation-actions {
        opacity: 0;
    }
    .conversation-item:hover .conversation-actions {
        opacity: 1;
    }
}

@media (hover: none), (pointer: coarse) {
    .conversation-actions {
        opacity: 1;
    }
}

.conversation-action-btn {
    background: transparent;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: #8e8e8e;
    transition: all 0.2s ease;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.conversation-action-btn:hover {
    background: #2d2d2d;
    color: #ECECF1;
}

.conversation-action-btn.delete-btn:hover {
    color: #f87171;
    background: rgba(248, 113, 113, 0.15);
}

.conversation-action-btn.rename-btn:hover {
    color: #60a5fa;
    background: rgba(96, 165, 250, 0.15);
}

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

.conversation-action-btn.loading {
    pointer-events: none;
    opacity: 0.6;
}

/* Three-dot menu button */
.conversation-menu-btn {
    background: transparent;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: #8e8e8e;
    transition: all 0.2s ease;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.conversation-menu-btn:hover {
    background: #2d2d2d;
    color: #ECECF1;
}

/* Conversation dropdown menu */
.conversation-dropdown {
    position: absolute;
    right: 20px;
    top: 50px;
    background: #2d2d2d;
    border: 1px solid #444654;
    border-radius: 20px;
    padding: 8px;
    min-width: 160px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.conversation-dropdown.hidden {
    display: none;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: #ECECF1;
    font-size: 0.9rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.dropdown-item:hover:not(.disabled) {
    background: #353542;
}

.dropdown-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.dropdown-item svg {
    flex-shrink: 0;
    color: #8e8e8e;
}

.dropdown-item.delete-item {
    color: #f87171;
}

.dropdown-item.delete-item svg {
    color: #f87171;
}

.dropdown-divider {
    height: 1px;
    background: #444654;
    margin: 8px 0;
}

.rename-modal {
    max-width: 400px;
}

.rename-modal .form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}

.btn-secondary {
    padding: 10px 20px;
    background: transparent;
    border: 1px solid #e2e8f0;
    border-radius: 9999px;
    cursor: pointer;
    color: #64748b;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.btn-secondary:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.btn-primary {
    padding: 10px 20px;
    background: #ECECF1; /* White background to match app theme */
    border: none;
    border-radius: 9999px;
    color: #171717; /* Dark text on white button */
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.btn-primary:hover {
    background: #ffffff; /* Brighter white on hover */
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.char-counter {
    font-size: 0.75rem;
    color: #94a3b8;
    text-align: right;
    margin-top: 4px;
}

.sidebar-footer {
    padding: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 13px;
    background: transparent;
    border-radius: 0;
}

.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #5e5e5e;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #ECECF1;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0;
    user-select: none;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 300;
    font-size: 0.8rem;
    color: #ECECF1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upgrade-btn-sidebar {
    flex-shrink: 0;
    padding: 4px 10px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 9999px;
    background: transparent;
    color: #ECECF1;
    font-size: 0.78rem;
    font-weight: 400;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.upgrade-btn-sidebar:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.4);
}


/* User Menu Dropdown */
.user-menu {
    position: absolute;
    bottom: 80px;
    left: 20px;
    right: 20px;
    background: #2d2d2d;
    border: 1px solid #444654;
    border-radius: 20px;
    padding: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

/* Collapsed sidebar: menu must escape the 50px sidebar.
   Switch to fixed positioning so it overlays the full page. */
.app-layout.sidebar-collapsed .user-menu {
    position: fixed;
    bottom: 80px;
    left: 8px;
    right: auto;
    width: 220px;
}

.user-menu.hidden {
    display: none;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    color: #ECECF1;
    font-size: 0.9rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.user-menu-item:hover {
    background: #353542;
}

.user-menu-item svg {
    flex-shrink: 0;
    color: #8e8e8e;
}

.user-menu-divider {
    height: 1px;
    background: #444654;
    margin: 8px 0;
}

.user-menu-item#menuLogout {
    color: #f87171;
}

.user-menu-item#menuLogout svg {
    color: #f87171;
}

/* Header toggle - hide it, we only use sidebar toggle now */
.header-left .desktop-only {
    display: none;
}

/* Other mobile/desktop elements */
.mobile-only {
    display: none;
}

.desktop-only {
    display: flex;
}

.container {
    width: 100%;
    height: 100vh;
    background: #212121;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header Styles */
.header {
    background: #212121;
    color: #ECECF1;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #2d2d2d;
    min-height: 60px;
    transition: all 0.3s ease;
    position: relative;
    z-index: 100; /* Above landing navigation to prevent covering */
}

/* Landing header - no bar background for anonymous users */
.header.landing-header {
    background: transparent;
    border-bottom: none;
    pointer-events: none; /* Don't intercept clicks over navigation links */
}

/* Re-enable pointer events for interactive elements inside landing header */
.header.landing-header .auth-section,
.header.landing-header .user-section,
.header.landing-header .sidebar-toggle,
.header.landing-header .logo {
    pointer-events: auto;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700; /* Bold - EDITITAN logo */
    margin: 0;
}

.logo p {
    font-size: 0.9rem;
    opacity: 0.9;
}

.auth-section, .user-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-right: 15px;
}

.user-name {
    font-weight: 500; /* Medium - user display name */
    font-size: 0.9rem;
}

/* Usage progress bar container */
.usage-container {
    position: relative;
    min-width: 140px;
    height: 20px;
}

/* Progress bar track (background with border) */
.usage-progress-bar {
    position: absolute;
    width: 100%;
    height: 10px;
    background: #4d4d4d;
    border: 2px solid #8e8e8e;
    border-radius: 10px;
    overflow: hidden;
    transition: opacity 0.3s ease;
    top: 50%;
    transform: translateY(-50%);
}

/* Progress bar fill (colored, dynamic width) */
.usage-progress-fill {
    height: 100%;
    transition: width 0.3s ease, background 0.3s ease;
    border-radius: 8px;
}

/* Color states based on usage percentage */
.usage-progress-fill.safe {
    background: #ECECF1;
}

.usage-progress-fill.warning {
    background: #fbbf24;
}

.usage-progress-fill.danger {
    background: #ef4444;
}

/* Text (hidden by default, shown on hover) */
.usage-text {
    position: absolute;
    width: 100%;
    font-size: 0.8rem;
    color: #8e8e8e;
    opacity: 0;
    transition: opacity 0.3s ease;
    white-space: nowrap;
    text-align: center;
    top: 50%;
    transform: translateY(-50%);
}

/* Hover state: fade out bar, fade in text */
.usage-container:hover .usage-progress-bar {
    opacity: 0;
}

.usage-container:hover .usage-text {
    opacity: 1;
}

.auth-btn {
    background: transparent;
    border: 1px solid #4d4d4d;
    color: #ECECF1;
    padding: 8px 16px;
    border-radius: 9999px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 400;
    transition: all 0.2s ease;
}

.auth-btn:hover {
    background: #2d2d2d;
}

.auth-btn.primary {
    background: #ECECF1;
    color: #171717;
    border-color: #ECECF1;
}

.auth-btn.primary:hover {
    background: #d1d5db;
}

.usage-display {
    font-size: 0.8rem;
    color: #64748b;
    margin-left: auto;
}

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 140px; /* Space for fixed input container */
    margin-right: 6px; /* Small gap between scrollbar and screen edge */
    background: #212121;
    position: relative; /* For floating button positioning */
    display: flex;
    flex-direction: column;
}

/* Landing Page Overlay */
.landing-page {
    position: fixed; /* Fixed to viewport, not container */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #212121;
    z-index: 50;
    pointer-events: none; /* Allow clicks to pass through to input */
}

.landing-page.hidden {
    display: none;
}

/* Authenticated landing: simple absolute+flexbox inside .chat-container.
   Avoids the position:fixed stacking issues of the anonymous overlay.
   No .landing-page class — that gets hidden by authenticated-mode rule. */
.authenticated-landing {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    pointer-events: none;
    z-index: 5;
}

.authenticated-landing.hidden {
    display: none;
}

.authenticated-landing .landing-heading {
    position: static;
    transform: none;
    color: #ECECF1;
    opacity: 0.9;
}

/* Navigation inline with header - same height as logo/buttons */
.landing-nav {
    position: fixed; /* Fixed to viewport */
    top: 20px; /* Same vertical position as header content */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 2rem;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    pointer-events: auto; /* Re-enable clicks for links */
    z-index: 9999; /* Above everything to ensure clickability */
    cursor: pointer;
}

.landing-nav a {
    color: #ECECF1;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 400;
    transition: color 0.2s ease;
    padding: 8px 16px;
}

.landing-nav a:hover {
    color: #5e5ee0;
}

/* Heading above input box */
.landing-heading {
    position: fixed; /* Fixed to viewport */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -280%); /* Center horizontally, position above center with more space */
    font-size: 2.75rem;
    font-weight: 600;
    color: #ECECF1;
    text-align: center;
    margin: 0;
    line-height: 1.2;
    white-space: nowrap;
    pointer-events: none;
}

/* Responsive landing page */
@media (max-width: 768px) {
    /* Nav links removed on mobile — too cluttered, only show on desktop */
    .landing-nav {
        display: none;
    }

    /* Input is at the bottom on mobile (not centered), so heading sits in
       the true vertical center of the space between header and input. */
    .landing-heading {
        font-size: 2rem;
        white-space: normal;
        max-width: 90%;
        top: 40%;
        transform: translate(-50%, -50%);
    }
}

@media (max-width: 480px) {
    .landing-heading {
        font-size: 1.5rem;
    }
}

/* Floating Upgrade Button */
.floating-upgrade-btn {
    position: sticky;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    width: fit-content;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, #5e5ee0 0%, #7b5ee8 100%);
    border-radius: 20px;
    padding: 10px 20px;
    box-shadow: 0 4px 12px rgba(94, 94, 224, 0.3);
    animation: fadeInDown 0.5s ease, subtlePulse 3s ease-in-out infinite;
    transition: all 0.3s ease;
}

.floating-upgrade-btn:hover {
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 16px rgba(94, 94, 224, 0.5);
}

.upgrade-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1;
}

.sparkle-icon {
    flex-shrink: 0;
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.5));
}

.close-upgrade-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #2d2d2d;
    border: 1px solid #4d4d4d;
    color: #8e8e8e;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    opacity: 0;
    transition: all 0.2s ease;
    padding: 0;
}

.close-upgrade-btn:hover {
    background: #3a3a3a;
    color: #ECECF1;
    border-color: #5e5ee0;
}

.floating-upgrade-btn:hover .close-upgrade-btn {
    opacity: 1;
}

/* Touch devices can't trigger :hover — always show dismiss button */
@media (hover: none), (pointer: coarse) {
    .close-upgrade-btn {
        opacity: 1;
    }
}

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

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

@keyframes subtlePulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(94, 94, 224, 0.3);
    }
    50% {
        box-shadow: 0 4px 16px rgba(94, 94, 224, 0.45);
    }
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 0 20px 20px 0; /* Right padding for spacing from scrollbar */
    max-width: 800px;
    margin: auto auto 0; /* margin-top: auto pushes messages to bottom, allows scrolling to top */
    width: 100%;
}

.message {
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease-in;
}

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

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700; /* Bold - avatar initials */
    font-size: 0.8rem;
    flex-shrink: 0;
}

.bot-avatar {
    background: #19c37d;
    color: white;
}

.user-message .user-avatar {
    background: #5e5e5e;
    color: white;
}

.message-content {
    padding: 12px 16px; /* Slimmer padding like ChatGPT */
    line-height: 1.6;
    color: #ECECF1;
    font-size: 16px; /* ChatGPT desktop font size */
    white-space: normal; /* Normal text wrapping */
    overflow-wrap: break-word; /* Break long words when necessary */
    word-break: normal; /* Normal word breaking */
}

.bot-message .message-content {
    background: transparent;
    border: none;
    box-shadow: none;
    flex: 1;
}

.user-message {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

.user-message .message-content {
    background: #303030;
    border-radius: 20px;
    max-width: 60%; /* Slimmer bubbles like ChatGPT */
    width: fit-content;
    transition: border-radius 0.15s ease;
}

.user-message .message-content.pill {
    border-radius: 9999px;
}

/* Phase 6: Visual branch indicators */
.message.has-branches {
    position: relative;
}

.message.has-branches::before {
    content: "🔀";
    position: absolute;
    left: -25px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    opacity: 0.4;
    transition: opacity 0.2s ease;
}

.message.has-branches:hover::before {
    opacity: 0.7;
}

/* Message actions (ChatGPT-style action buttons below messages) */
.message-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    padding-left: 15px;
}

/* Action buttons (copy, like, etc.) */
.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #8e8e8e;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #ECECF1;
}

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

.action-btn.copied {
    color: #19c37d;
}

.action-btn.active {
    color: #19c37d;
}

.action-btn.like-btn.active {
    color: #19c37d;  /* Green for like */
}

.action-btn.dislike-btn.active {
    color: #f87171;  /* Red for dislike */
}

.action-btn.edit-btn {
    font-size: 16px;
    font-weight: 500;
    margin-top: 8px;
}

.action-btn.edit-btn:hover {
    color: #4facfe;
}

.action-btn svg {
    flex-shrink: 0;
}

/* Edit button: show on hover (ChatGPT pattern) */
.user-message .action-btn.edit-btn {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.user-message:hover .action-btn.edit-btn {
    opacity: 1;
}

/* Mobile/touch: always show */
@media (hover: none) {
    .user-message .action-btn.edit-btn {
        opacity: 1;
    }
}

/* Edit message inline editor */
.edit-textarea {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    background: #2f2f2f;
    border: 1px solid #444;
    border-radius: 8px;
    color: #ECECF1;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.6;
    resize: none;
    margin-bottom: 12px;
}

.edit-textarea:focus {
    outline: none;
    border-color: #666;
    box-shadow: 0 0 0 1px #666;
}

.edit-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.save-edit-btn,
.cancel-edit-btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.save-edit-btn {
    background: #4facfe;
    color: white;
}

.save-edit-btn:hover {
    background: #3b8bce;
}

.cancel-edit-btn {
    background: #2f2f2f;
    color: #ECECF1;
    border: 1px solid #444;
}

.cancel-edit-btn:hover {
    background: #3f3f3f;
}

/* Version navigation (for retry feature) */
.version-navigation {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding-left: 15px;
}

.version-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: transparent;
    border: 1px solid rgba(142, 142, 142, 0.3);
    border-radius: 4px;
    color: #8e8e8e;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
    font-size: 14px;
    line-height: 1;
}

.version-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
    color: #ECECF1;
    border-color: rgba(236, 236, 241, 0.3);
}

.version-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.version-counter {
    font-size: 0.85rem;
    color: #8e8e8e;
    user-select: none;
    min-width: 45px;
    text-align: center;
}

/* Loading spinner for retry button */
.loading-spinner {
    display: inline-block;
    animation: spin 1s linear infinite;
}

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

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 15px 20px;
    background: transparent;
    color: #8e8e8e;
    font-size: 0.9rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 2px;
    align-self: flex-end;
    margin-bottom: 4px;
}

.typing-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #8e8e8e;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: scale(0.8); opacity: 0.5; }
    30% { transform: scale(1.2); opacity: 1; }
}

/* Loading indicator for older messages (Phase 3.4: Lazy Loading) */
.loading-older-messages {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(33, 33, 33, 0.95);
    backdrop-filter: blur(8px);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-bottom: 1px solid #333;
}

.loading-older-messages.hidden {
    display: none;
}

.loading-spinner-container {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #999;
    font-size: 14px;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #333;
    border-top-color: #4facfe;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Input Container - transparent wrapper for input only */
.input-container {
    padding: 20px 20px 0 20px; /* No bottom padding - disclaimer has its own section */
    background: transparent;
    border-top: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: fixed;
    bottom: 35px; /* Height of disclaimer section below */
    left: 0;
    right: 0;
    z-index: 40; /* Above messages, below modals */
    /* No transition here — transition is only active when sidebar is visible
       to avoid mid-flight animation on logout (left:260px → 0 → 50% flash) */
}

/* Center input when landing page is active */
.container.landing-mode .input-container {
    position: fixed;
    bottom: 50%;
    left: 50%;
    transform: translate(-50%, 50%);
    width: 100%;
    z-index: 60; /* Above landing page overlay */
}

/* input-info is now a sibling of input-container (not a child), so
   position:fixed always targets the viewport — no landing-mode override needed. */

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: transparent;
    border-radius: 24px;
    padding: 0;
    border: none;
    position: relative;
    max-width: 800px;
    width: 100%;
}

.char-count-inline {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 60px;
    font-size: 0.75rem;
    color: #8e8e8e;
    pointer-events: none;
    user-select: none;
    z-index: 10;
}

/* Textarea wrapper - creates visual bubble with border-radius */
.textarea-wrapper {
    flex: 1;
    position: relative;
    border: 1px solid #424242;
    background: #303030;
    border-radius: 26px;
    overflow: hidden;
    transition: border-color 0.2s ease;
    max-height: 120px;
}

.textarea-wrapper:focus-within {
    border-color: #8e8e8e;
}

/* Textarea itself - no border, fills wrapper */
#messageInput {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    background: transparent;
    padding: 12px 130px 12px 16px;
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    line-height: 1.5;
    color: #ECECF1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Custom scrollbar styling - now clipped by wrapper's border-radius */
#messageInput::-webkit-scrollbar {
    width: 6px;
}

#messageInput::-webkit-scrollbar-track {
    background: transparent;
    margin: 8px 0;
}

#messageInput::-webkit-scrollbar-thumb {
    background: #5e5e5e;
    border-radius: 3px;
}

#messageInput::-webkit-scrollbar-thumb:hover {
    background: #8e8e8e;
}

#messageInput::placeholder {
    color: #8e8e8e;
}

.send-button {
    background: #ECECF1;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #171717;
    flex-shrink: 0;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}

.send-button:hover:not(:disabled) {
    background: #d1d5db;
}

.send-button:disabled {
    background: #5e5e5e;
    color: #8e8e8e;
    cursor: not-allowed;
}

.stop-button {
    background: #6b7280; /* Light grey instead of red */
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
    flex-shrink: 0;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}

.stop-button svg {
    width: 18px;
    height: 18px;
}

.stop-button:hover {
    background: #9ca3af; /* Lighter grey on hover */
}

.input-info {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 300;
    color: #ECECF1;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 35px;
    margin: 0 auto;
    width: 100%;
    background: #212121; /* Opaque background to obscure scrolling messages */
    z-index: 55; /* Above landing-page overlay (50), below input-container landing-mode (60) */
    pointer-events: none;
}

.disclaimer-text a {
    pointer-events: auto;
}

/* Desktop only: offset input/disclaimer for sidebar width.
   Wrapped in min-width so these never leak to mobile. */
@media (min-width: 769px) {
    /* Transition only when sidebar is present — prevents mid-flight animation
       on logout where left animates 260px→0→50% causing a stuck position flash */
    .app-layout:not(.no-sidebar) .input-container,
    .app-layout:not(.no-sidebar) .input-info {
        transition: left 0.3s ease, width 0.3s ease;
    }

    .app-layout:not(.sidebar-collapsed):not(.no-sidebar) .input-container {
        left: 260px;
        right: 0;
        width: calc(100% - 260px);
    }

    .app-layout.sidebar-collapsed:not(.no-sidebar) .input-container {
        left: 50px;
        right: 0;
        width: calc(100% - 50px);
    }

    .app-layout:not(.sidebar-collapsed):not(.no-sidebar) .input-info {
        left: 260px;
        width: calc(100% - 260px);
    }

    .app-layout.sidebar-collapsed:not(.no-sidebar) .input-info {
        left: 50px;
        width: calc(100% - 50px);
    }

}

.disclaimer-text {
    font-size: 0.8rem;
    font-weight: 300;
    color: #999;
    text-align: center;
}

.disclaimer-link {
    color: #999;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.disclaimer-link:hover {
    color: #5e5ee0;
}

.usage-display {
    font-size: 0.75rem;
    color: #8e8e8e;
    position: absolute;
    right: 0;
}

.footer {
    background: #1e293b;
    color: white;
    text-align: center;
    padding: 15px 20px;
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

/* When JavaScript sets display:block, ensure flexbox centering */
.modal[style*="display: block"],
.modal[style*="display:block"] {
    display: flex !important;
}

.modal-content {
    background-color: #2d2d2d; /* Dark theme background */
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 1px solid #4d4d4d; /* Subtle border */
    max-width: 500px;
    width: 90%;
    position: relative;
}

.close {
    color: #8e8e8e; /* Light gray for dark theme */
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    right: 20px;
    top: 15px;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close:hover {
    color: #ECECF1; /* Brighter on hover */
}

/* Auth Modal Styles */
.auth-modal {
    max-width: 450px;
    padding: 40px;
}

.auth-form h2 {
    text-align: center;
    margin-bottom: 8px;
    color: #ECECF1; /* Light text for dark theme */
    font-size: 1.8rem;
    font-weight: 700; /* Bold - modal titles */
}

.auth-subtitle {
    text-align: center;
    color: #8e8e8e; /* Muted light text */
    margin-bottom: 30px;
    font-size: 0.9rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: #ECECF1; /* Light text for dark theme */
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #4d4d4d; /* Dark border */
    border-radius: 9999px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #1e1e1e; /* Dark input background */
    color: #ECECF1; /* Light text */
}

.form-group input:focus {
    outline: none;
    border-color: #4facfe;
    background: #2d2d2d; /* Slightly lighter on focus */
}

.form-group small {
    color: #8e8e8e; /* Muted light text */
    font-size: 0.8rem;
    margin-top: 4px;
    display: block;
}

/* Password Reset Modal - Proper spacing and centering */
.password-reset-modal {
    max-width: 480px !important;
    padding: 40px 50px !important;
}

.password-reset-modal h2 {
    text-align: center;
    margin-bottom: 12px;
    font-size: 1.5rem;
    font-weight: 600;
    color: #ECECF1;
}

.password-reset-modal .modal-description {
    text-align: center;
    color: #8e8e8e;
    font-size: 0.95rem;
    margin-bottom: 32px;
    line-height: 1.5;
}

.password-reset-modal .form-group {
    margin-bottom: 24px;
}

.password-reset-modal .form-group:last-of-type {
    margin-bottom: 32px;
}

.password-reset-modal .form-group label {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.password-reset-modal .form-group input {
    padding: 14px 16px;
    font-size: 1rem;
}

.password-reset-modal .form-group small {
    margin-top: 6px;
}

.password-reset-modal .form-actions {
    display: flex;
    justify-content: center;
    margin-top: 0;
}

.password-reset-modal .form-actions button {
    min-width: 180px;
    max-width: 100%;
    padding: 14px 32px;
    font-size: 1rem;
    font-weight: 600;
}

@media (max-width: 768px) {
    .password-reset-modal {
        padding: 30px 24px !important;
        max-width: 90% !important;
    }

    .password-reset-modal h2 {
        font-size: 1.3rem;
    }

    .password-reset-modal .form-actions button {
        width: 100%;
    }
}

.auth-submit-btn {
    width: 100%;
    background: #ECECF1; /* White background to match app theme */
    color: #171717; /* Dark text on white button */
    border: none;
    padding: 14px;
    border-radius: 9999px;
    font-size: 1rem;
    font-weight: 700; /* Bold - button text */
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
    position: relative;
}

.auth-submit-btn:hover {
    transform: translateY(-1px);
    background: #ffffff; /* Brighter white on hover */
    box-shadow: 0 4px 15px rgba(236, 236, 241, 0.3);
}

.auth-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-loader {
    display: none;
}

.auth-submit-btn:disabled .btn-text {
    display: none;
}

.auth-submit-btn:disabled .btn-loader {
    display: inline;
}

.auth-switch {
    text-align: center;
    color: #8e8e8e; /* Light muted text for dark theme */
    font-size: 0.9rem;
}

.auth-switch a {
    color: #ECECF1; /* White to match app theme */
    text-decoration: none;
    font-weight: 500;
}

.auth-switch a:hover {
    text-decoration: underline;
    color: #ffffff; /* Brighter white on hover */
}

/* Auth Success */
.auth-success {
    text-align: center;
    padding: 20px;
}

.success-icon {
    background: #10b981;
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 20px;
}

.auth-success h3 {
    margin-bottom: 10px;
    color: #ECECF1; /* Light text for dark theme */
}

.auth-success p {
    color: #8e8e8e; /* Muted light text */
}

/* Upgrade Modal */
.upgrade-modal {
    max-width: 600px;
    padding: 40px 30px; /* More padding for breathing room */
}

.upgrade-modal h2 {
    text-align: center;
    margin-bottom: 30px; /* More space below title */
    color: #ECECF1; /* Light text for dark theme */
}

.upgrade-modal > p {
    text-align: center;
    color: #8e8e8e; /* Muted light text */
    margin-bottom: 0;
}

.upgrade-modal > p.mt-20 {
    margin-bottom: 20px; /* Space after "View Full Pricing Details" */
}

.pricing-plans {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 20px;
    margin-bottom: 30px; /* More space below pricing cards */
}

.plan {
    border: 2px solid #4d4d4d; /* Dark border */
    border-radius: 12px;
    padding: 24px 16px;
    text-align: center;
    position: relative;
    transition: all 0.3s ease;
    background: #1e1e1e; /* Dark background */
}

.plan:hover {
    border-color: #4facfe;
    transform: translateY(-2px);
}

.plan.recommended {
    border-color: #4facfe;
    background: linear-gradient(135deg, rgba(79, 172, 254, 0.15), rgba(0, 242, 254, 0.15));
}

.plan.recommended::before {
    content: "Recommended";
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: #4facfe;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700; /* Bold - badge text */
}

.plan h3 {
    margin-bottom: 12px;
    color: #ECECF1; /* Light text for dark theme */
    font-size: 1.2rem;
}

.plan .price {
    font-size: 2rem;
    font-weight: 700;
    color: #4facfe;
    margin-bottom: 8px;
}

.plan .price span {
    font-size: 1rem;
    font-weight: 400;
    color: #8e8e8e; /* Muted light text */
}

.plan p {
    color: #8e8e8e; /* Muted light text */
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.plan-btn {
    background: #ECECF1; /* White background to match app theme */
    color: #171717; /* Dark text on white button */
    border: none;
    padding: 10px 20px;
    border-radius: 9999px;
    font-weight: 700; /* Bold - button text */
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.plan-btn:hover {
    transform: translateY(-1px);
    background: #ffffff; /* Brighter white on hover */
    box-shadow: 0 4px 15px rgba(236, 236, 241, 0.3);
}

/* Sidebar Responsive Breakpoints */
@media (max-width: 1024px) {
    .app-layout {
        grid-template-columns: 240px 1fr;
    }

    .sidebar {
        width: 240px;
    }
}

/* ══════════════════════════════════════════════════════════════════
   MOBILE — single merged block
   ChatGPT pattern: position:fixed shell, pure flex children,
   no sticky, no viewport-height units → immune to Safari toolbar.
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* ── Layout Shell ─────────────────────────────────────────────
       Fixed outer shell fills the visual viewport. No dvh/vh —
       layout never resizes when Safari's bottom toolbar moves.
       top uses safe-area-inset so Safari's native banners (e.g.
       "Reduce Protections") can render above the app, not behind
       the notch. */
    .app-layout {
        grid-template-columns: 1fr;
        position: fixed;
        top: env(safe-area-inset-top, 0px);
        right: 0;
        bottom: 0;
        left: 0;
        height: auto;
    }

    .container {
        height: 100%;
        min-height: 0;
        border-radius: 0;
    }

    /* ── Header ───────────────────────────────────────────────────
       Relative flex child — sits at top, never scrolls.
       Safe-area top is handled by .app-layout's top offset,
       so header only needs normal padding. */
    .header {
        position: relative;
        flex-shrink: 0;
        z-index: 100;
        padding-top: 10px;
        padding-right: max(15px, env(safe-area-inset-right, 0px));
        padding-bottom: 10px;
        padding-left: max(15px, env(safe-area-inset-left, 0px));
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        text-align: left;
        border-bottom: none;
    }

    /* Landing header: slightly more horizontal padding */
    .header.landing-header {
        padding-right: max(20px, env(safe-area-inset-right, 0px));
        padding-left: max(20px, env(safe-area-inset-left, 0px));
    }

    /* ── Sidebar (mobile drawer) ──────────────────────────────── */
    .sidebar {
        position: fixed;
        top: 0;
        left: -260px;
        width: 260px;
        height: 100%;
        z-index: 1000;
        transition: left 0.3s ease;
        background: #181818;
        /* iOS Safari safe areas */
        padding-top: env(safe-area-inset-top, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
        padding-left: env(safe-area-inset-left, 0);
    }

    .sidebar.open {
        left: 0;
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.15);
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: all;
    }

    /* ── Header controls ──────────────────────────────────────── */
    .sidebar-toggle.mobile-only {
        display: flex;
    }

    /* Hide hamburger for anonymous users — no sidebar to open */
    .app-layout.no-sidebar .sidebar-toggle.mobile-only {
        display: none;
    }

    /* Remove hamburger border on mobile — ChatGPT style is borderless */
    .sidebar-toggle {
        border: none;
        padding: 10px;
    }

    .header-left .desktop-only {
        display: none;
    }

    .mobile-only {
        display: flex;
    }

    .desktop-only {
        display: none;
    }

    /* Progress bar + Sign Out live in the sidebar on mobile */
    .user-section {
        display: none !important;
    }

    /* Header-left: hamburger + logo in a tight row */
    .header-left {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .auth-section {
        justify-content: flex-end;
    }

    /* Smaller logo on mobile — matches ChatGPT's subtle branding */
    .logo h1 {
        font-size: 1.25rem;
        font-weight: 600;
    }

    .logo p {
        font-size: 0.8rem;
    }

    /* Hide char counter on mobile — ChatGPT doesn't show it */
    .char-count-inline {
        display: none;
    }

    /* Hide Sign Up — user reaches it via the Sign In modal's "Sign up" link */
    #signupBtn {
        display: none;
    }

    /* Style Log In as a white pill button (matches ChatGPT mobile) */
    #loginBtn {
        background: white;
        color: #171717;
        border-color: white;
        font-weight: 500;
        padding: 8px 22px;
        border-radius: 20px;
    }

    .user-info {
        align-items: center;
        margin-right: 0;
        margin-bottom: 0;
    }

    /* ── Chat area ────────────────────────────────────────────── */
    .chat-container {
        padding: 15px;
        padding-bottom: 20px;
        margin-right: 4px;
        min-height: 0; /* Critical for flex-child scrolling */
    }

    /* Floating Upgrade Button - Mobile */
    .floating-upgrade-btn {
        top: 10px;
        padding: 8px 16px;
        margin-bottom: 15px;
    }

    .upgrade-link {
        font-size: 0.85rem;
        gap: 6px;
    }

    .sparkle-icon {
        width: 14px;
        height: 14px;
    }

    .close-upgrade-btn {
        top: -6px;
        right: -6px;
        width: 18px;
        height: 18px;
        font-size: 14px;
    }

    .message-content {
        padding: 12px 15px;
        font-size: 14px; /* ChatGPT mobile font size */
    }

    /* Reduce spacing around messages on mobile */
    .message {
        margin-bottom: 12px;
    }

    /* Reduce gap between message content and copy button */
    .message-actions {
        margin-top: 4px;
        gap: 8px;
    }

    /* ── Input area ─────────────────────────────────────────────
       Relative flex child — sits at bottom, no !important needed.
       Desktop fixed/landing-mode rules are overridden by specificity. */
    .input-container {
        position: relative;
        flex-shrink: 0;
        bottom: auto;
        left: auto;
        right: auto;
        width: 100%;
        transform: none;
        margin-bottom: 0;
        padding: 8px 16px 0 16px;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: #212121;
        z-index: 50;
    }

    /* Landing mode: override desktop centered positioning on mobile */
    .container.landing-mode .input-container {
        position: relative;
        bottom: auto;
        left: auto;
        transform: none;
        width: 100%;
    }

    /* Prevent desktop sidebar-offset rules from leaking to mobile */
    .app-layout .input-container,
    .app-layout .input-info {
        left: auto;
        width: 100%;
    }

    /* ChatGPT-style input: darker, more integrated with background */
    .textarea-wrapper {
        background: #303030;
        border-color: #424242;
    }

    /* Adjust textarea padding since we hid the char counter */
    #messageInput {
        padding: 12px 60px 12px 16px;
    }

    /* Disclaimer */
    .input-info {
        position: relative;
        display: block;
        width: 100%;
        height: auto;
        padding: 4px 0 2px 0;
        margin: 0;
        text-align: center;
        background: #212121;
    }

    /* Smaller, more subtle disclaimer like ChatGPT */
    .disclaimer-text {
        font-size: 0.75rem;
        color: #888;
    }

    .modal-content {
        margin: 20px;
        padding: 25px;
    }

    .auth-modal {
        padding: 30px 25px;
    }

    .pricing-plans {
        grid-template-columns: 1fr;
    }

    /* Hide upgrade modal on mobile - desktop only feature */
    .upgrade-modal {
        display: none !important;
    }
}

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

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

.chat-container::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: #6b6b6b;
}

/* Sidebar scrollbar - auto-hide */
.conversations-list::-webkit-scrollbar {
    width: 6px;
}

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

.conversations-list::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 3px;
    transition: background 0.3s ease;
}

.conversations-list:hover::-webkit-scrollbar-thumb {
    background: #464646;
}

.conversations-list::-webkit-scrollbar-thumb:hover {
    background: #5e5e5e;
}

/* For Firefox */
.conversations-list {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

.conversations-list:hover {
    scrollbar-color: #464646 transparent;
}

/* ============================================
   MARKDOWN CONTENT STYLING
   ============================================ */

/* Markdown container - applies to all bot messages */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin-top: 24px;
    margin-bottom: 12px;
    font-weight: 700; /* Bold - matches HelveticaNeue-Bold.otf */
    line-height: 1.3;
    color: #ECECF1;
}

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

.message-content h1 {
    font-size: 2em;
}

.message-content h2 {
    font-size: 1.6em;
}

.message-content h3 {
    font-size: 1.4em;
}

.message-content h4 {
    font-size: 1.2em;
}

.message-content h5 {
    font-size: 1.1em;
}

.message-content h6 {
    font-size: 1em;
    color: #b4b4b4;
}

/* Paragraphs */
.message-content p {
    margin: 12px 0;
    line-height: 1.7;
}

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

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

/* Lists */
.message-content ul,
.message-content ol {
    margin: 12px 0;
    padding-left: 28px;
}

.message-content ul {
    list-style-type: disc;
}

.message-content ol {
    list-style-type: decimal;
}

.message-content li {
    margin: 6px 0;
    line-height: 1.6;
    color: #ECECF1;
}

.message-content li > ul,
.message-content li > ol {
    margin-top: 6px;
    margin-bottom: 6px;
}

/* Nested lists */
.message-content ul ul {
    list-style-type: circle;
}

.message-content ul ul ul {
    list-style-type: square;
}

/* Bold and Italic */
.message-content strong {
    font-weight: 700; /* Bold - matches HelveticaNeue-Bold.otf */
    color: #ECECF1;
}

.message-content em {
    font-style: italic;
    color: #d4d4d4;
}

/* Links */
.message-content a {
    color: #60a5fa;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.message-content a:hover {
    border-bottom-color: #60a5fa;
    color: #93c5fd;
}

/* Inline Code */
.message-content code {
    background: #2d2d2d;
    color: #f472b6;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'Courier New', Courier, monospace;
    border: 1px solid #404040;
}

/* Code Blocks */
.message-content pre {
    background: #1a1a1a;
    border: 1px solid #404040;
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
    overflow-x: auto;
    line-height: 1.5;
}

.message-content pre code {
    background: transparent;
    color: #ECECF1;
    padding: 0;
    border: none;
    font-size: 0.9em;
    display: block;
}

/* Code block scrollbar */
.message-content pre::-webkit-scrollbar {
    height: 8px;
}

.message-content pre::-webkit-scrollbar-track {
    background: #2d2d2d;
    border-radius: 4px;
}

.message-content pre::-webkit-scrollbar-thumb {
    background: #4d4d4d;
    border-radius: 4px;
}

.message-content pre::-webkit-scrollbar-thumb:hover {
    background: #5e5e5e;
}

/* Blockquotes - removed styling to match normal text */
.message-content blockquote {
    margin: 16px 0;
    padding: 0;
    color: #ECECF1;
    font-style: normal;
}

.message-content blockquote p {
    margin: 0;
}

.message-content blockquote cite {
    display: block;
    margin-top: 8px;
    font-size: 0.9em;
    color: #8e8e8e;
}

/* Horizontal Rule */
.message-content hr {
    border: none;
    border-top: 1px solid #4d4d4d;
    margin: 24px 0;
}

/* Tables */
.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    overflow-x: auto;
    display: block;
}

.message-content thead {
    background: #2d2d2d;
}

.message-content th {
    padding: 12px;
    text-align: left;
    font-weight: 700; /* Bold - matches HelveticaNeue-Bold.otf */
    color: #ECECF1;
    border: 1px solid #4d4d4d;
}

.message-content td {
    padding: 10px 12px;
    border: 1px solid #4d4d4d;
    color: #d4d4d4;
}

.message-content tr:nth-child(even) {
    background: #242424;
}

.message-content tr:hover {
    background: #303030;
}

/* Images */
.message-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 12px 0;
    display: block;
}

/* Task Lists (GitHub-style) */
.message-content input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.message-content .task-list-item {
    list-style-type: none;
    margin-left: -20px;
}

/* Keyboard Keys */
.message-content kbd {
    background: #2d2d2d;
    border: 1px solid #4d4d4d;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.9em;
    font-family: 'Courier New', Courier, monospace;
    box-shadow: 0 2px 0 #1a1a1a;
}

/* Strikethrough */
.message-content del,
.message-content s {
    color: #8e8e8e;
    text-decoration: line-through;
}

/* Mark/Highlight */
.message-content mark {
    background: #fbbf24;
    color: #1a1a1a;
    padding: 2px 4px;
    border-radius: 2px;
}

/* Subscript and Superscript */
.message-content sub,
.message-content sup {
    font-size: 0.75em;
}

/* Definition Lists */
.message-content dl {
    margin: 12px 0;
}

.message-content dt {
    font-weight: 700; /* Bold - matches HelveticaNeue-Bold.otf */
    color: #ECECF1;
    margin-top: 12px;
}

.message-content dd {
    margin-left: 24px;
    margin-top: 4px;
    color: #d4d4d4;
}

/* Abbreviations */
.message-content abbr {
    text-decoration: underline dotted;
    cursor: help;
    color: #60a5fa;
}

/* Details/Summary (collapsible sections) */
.message-content details {
    background: #2d2d2d;
    border: 1px solid #4d4d4d;
    border-radius: 6px;
    padding: 12px;
    margin: 12px 0;
}

.message-content summary {
    cursor: pointer;
    font-weight: 700; /* Bold - matches HelveticaNeue-Bold.otf */
    color: #ECECF1;
    user-select: none;
}

.message-content summary:hover {
    color: #60a5fa;
}

.message-content details[open] summary {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #4d4d4d;
}

/* Search Chats Modal */
.search-chats-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
}

.search-chats-modal.hidden {
    display: none;
}

.search-chats-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.search-chats-dialog {
    position: relative;
    background: #2d2d2d;
    border: 1px solid #444;
    border-radius: 16px;
    width: 90%;
    max-width: 560px;
    max-height: 60vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.search-chats-header {
    display: flex;
    align-items: center;
    padding: 16px;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.search-chats-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #ECECF1;
    font-size: 1rem;
    outline: none;
    font-family: inherit;
}

.search-chats-input::placeholder {
    color: #8e8e8e;
}

.search-chats-close {
    background: transparent;
    border: none;
    color: #8e8e8e;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease;
}

.search-chats-close:hover {
    color: #ECECF1;
}

.search-chats-results {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    scrollbar-width: thin;
    scrollbar-color: #464646 transparent;
}

.search-chats-results::-webkit-scrollbar {
    width: 6px;
}

.search-chats-results::-webkit-scrollbar-track {
    background: transparent;
}

.search-chats-results::-webkit-scrollbar-thumb {
    background: #464646;
    border-radius: 3px;
}

.search-chats-results::-webkit-scrollbar-thumb:hover {
    background: #5e5e5e;
}

.search-chats-group-label {
    padding: 8px 12px 4px 12px;
    font-size: 0.75rem;
    color: #8e8e8e;
    font-weight: 500;
}

.search-chats-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
    color: #ECECF1;
    font-size: 0.875rem;
}

.search-chats-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.search-chats-item svg {
    flex-shrink: 0;
    color: #b4b4b4;
}

.search-chats-empty {
    padding: 24px;
    text-align: center;
    color: #8e8e8e;
    font-size: 0.875rem;
}

/* Settings Modal Styles */

/* Make sidebar user profile clickable */
.user-profile.clickable {
    cursor: pointer;
    transition: background 0.15s ease;
    position: relative;
}

.user-profile.clickable:hover {
    background: rgba(255, 255, 255, 0.08);
}

.user-profile .settings-icon {
    display: none;
}

/* Settings modal - wider than regular modals */
.settings-modal {
    max-width: 700px !important;
    width: 90% !important;
    max-height: 85vh;
    overflow-y: auto;
}

/* Settings tabs navigation */
.settings-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid #2f2f2f;
    margin: 20px 0;
}

.settings-tab {
    background: none;
    border: none;
    color: #8e8ea0;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.settings-tab:hover {
    color: #ececf1;
}

.settings-tab.active {
    color: #4facfe;
    border-bottom-color: #4facfe;
}

/* Settings tab content */
.settings-tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.settings-tab-content.active {
    display: block;
}

.settings-tab-content h3 {
    color: #ececf1;
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 20px 0;
}

.settings-tab-content h4 {
    color: #ececf1;
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 6px 0;
}

.settings-tab-content p {
    color: #8e8ea0;
    font-size: 14px;
    margin: 0;
    line-height: 1.5;
}

.settings-tab-content small {
    color: #8e8ea0;
    font-size: 13px;
    display: block;
    margin-top: 6px;
}

/* Settings sections */
.settings-section {
    margin-bottom: 30px;
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: #1e1e1e;
    border: 1px solid #2f2f2f;
    border-radius: 20px;
    margin-bottom: 16px;
}

.settings-item-info {
    flex: 1;
}

.settings-item button {
    flex-shrink: 0;
    white-space: nowrap;
}

/* Subscription info */
.subscription-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    background: #1e1e1e;
    border: 1px solid #2f2f2f;
    border-radius: 20px;
}

.plan-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.plan-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    text-transform: capitalize;
}

.plan-status {
    font-size: 12px;
    color: #888;
}

.subscription-actions {
    display: flex;
    gap: 8px;
}

.btn-small {
    padding: 8px 16px;
    font-size: 13px;
}

.upgrade-link-inline {
    color: #4facfe;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}

.upgrade-link-inline:hover {
    text-decoration: underline;
}

/* Danger Zone */
.danger-zone {
    border: 2px solid #ef4444;
    border-radius: 20px;
    padding: 20px;
    background: rgba(239, 68, 68, 0.05);
}

.danger-zone-title {
    color: #ef4444;
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 16px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Button variants */
.btn-secondary {
    background: #2f2f2f;
    color: #ececf1;
    border: 1px solid #4d4d4d;
    padding: 10px 20px;
    border-radius: 9999px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-secondary:hover:not(:disabled) {
    background: #3f3f3f;
    border-color: #5d5d5d;
}

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

.btn-danger {
    background: #ef4444;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 9999px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

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

.btn-primary {
    background: #ECECF1; /* White background to match app theme */
    color: #171717; /* Dark text on white button */
    border: none;
    padding: 12px 24px;
    border-radius: 9999px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s ease;
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    background: #ffffff; /* Brighter white on hover */
    box-shadow: 0 4px 12px rgba(236, 236, 241, 0.3);
}

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

/* Delete confirmation modals */
.delete-confirm-modal {
    max-width: 500px !important;
}

.warning-box {
    background: rgba(251, 191, 36, 0.1);
    border: 2px solid #fbbf24;
    border-radius: 20px;
    padding: 16px;
    margin: 20px 0;
}

.warning-box p {
    color: #ececf1;
    margin: 8px 0;
    font-size: 14px;
    line-height: 1.6;
}

.warning-box strong {
    color: #fbbf24;
    font-weight: 700;
}

.warning-box ul {
    margin: 12px 0 8px 20px;
    color: #d4d4d4;
}

.warning-box li {
    margin: 6px 0;
    font-size: 14px;
}

/* Form actions */
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: flex-end;
}

.form-actions button {
    flex: 1;
    max-width: 150px;
}

/* Settings form groups - override defaults for settings modal */
.settings-modal .form-group {
    margin-bottom: 20px;
}

.settings-modal .form-group label {
    color: #ececf1;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
}

.settings-modal .form-group input[type="text"],
.settings-modal .form-group input[type="email"] {
    width: 100%;
    background: #2f2f2f;
    border: 1px solid #4d4d4d;
    color: #ececf1;
    padding: 12px;
    border-radius: 6px;
    font-size: 15px;
    transition: all 0.2s ease;
}

.settings-modal .form-group input:focus {
    outline: none;
    border-color: #4facfe;
    background: #1e1e1e;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .settings-modal {
        width: 95% !important;
        max-height: 90vh;
    }

    .settings-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .settings-item button {
        width: 100%;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions button {
        max-width: none;
    }

    .settings-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 4px;
    }

    .settings-tab {
        flex-shrink: 0;
        padding: 10px 12px;
        font-size: 13px;
        white-space: nowrap;
    }
}

/* ============================================
   SUBSCRIPTION CARD (Settings Modal)
   ============================================ */
.subscription-section {
    margin-top: 8px;
}

.subscription-card {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 20px;
    padding: 20px;
}

.subscription-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.plan-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.plan-badge {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: #000;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    text-transform: capitalize;
}

.plan-badge.free {
    background: #333;
    color: #999;
}

.plan-status {
    font-size: 12px;
    color: #f59e0b;
}

.plan-status.cancelled {
    color: #ef4444;
}

.plan-status.scheduled {
    color: #3b82f6;
}

.plan-price {
    text-align: right;
}

.plan-price .price-amount {
    font-size: 24px;
    font-weight: 700;
    color: #fff;
}

.plan-price .price-period {
    font-size: 14px;
    color: #888;
}

/* Usage Section */
.usage-section {
    margin-bottom: 16px;
}

.usage-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.usage-label {
    font-size: 13px;
    color: #888;
}

.usage-count {
    font-size: 13px;
    color: #ececf1;
    font-weight: 500;
}

.usage-bar {
    height: 6px;
    background: #333;
    border-radius: 3px;
    overflow: hidden;
}

.usage-progress {
    height: 100%;
    background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
    border-radius: 3px;
    transition: width 0.3s ease;
}

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

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

/* Payment Method */
.payment-method {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: #252525;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    color: #ececf1;
}

.payment-method svg {
    color: #888;
}

/* Subscription Actions */
.subscription-actions {
    margin-top: 16px;
}

.btn-full {
    width: 100%;
    text-align: center;
    display: block;
}

.paid-actions {
    display: flex;
    gap: 12px;
}

.paid-actions button {
    flex: 1;
}

.btn-outline-danger {
    background: transparent;
    border: 1px solid #ef4444;
    color: #ef4444;
    padding: 10px 20px;
    border-radius: 9999px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-outline-danger:hover {
    background: #ef4444;
    color: #fff;
}

/* ============================================
   CHANGE PLAN MODAL
   ============================================ */
.change-plan-modal {
    width: 500px;
    max-width: 95vw;
}

.modal-subtitle {
    color: #888;
    margin-bottom: 20px;
    font-size: 14px;
}

/* Billing Toggle Small */
.billing-toggle-small {
    display: flex;
    background: #1a1a1a;
    border-radius: 9999px;
    padding: 4px;
    margin-bottom: 20px;
}

.billing-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: #888;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 9999px;
    transition: all 0.2s ease;
}

.billing-btn.active {
    background: #333;
    color: #fff;
}

.billing-btn:hover:not(.active) {
    color: #ececf1;
}

.save-tag {
    background: #10b981;
    color: #fff;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
}

/* Plan Options */
.plan-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.plan-option {
    display: block;
    cursor: pointer;
}

.plan-option input[type="radio"] {
    display: none;
}

.plan-option-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: #1a1a1a;
    border: 2px solid #333;
    border-radius: 9999px;
    transition: all 0.2s ease;
}

.plan-option:hover .plan-option-content {
    border-color: #444;
}

.plan-option input:checked + .plan-option-content {
    border-color: #4facfe;
    background: #1e2a3a;
}

.plan-option.current-plan .plan-option-content {
    border-color: #333;
    background: #252525;
    opacity: 0.7;
}

.plan-option-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.plan-option-name {
    font-size: 16px;
    font-weight: 600;
    color: #ececf1;
}

.plan-option-current {
    background: #333;
    color: #888;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
}

.plan-option-price {
    text-align: right;
}

.plan-option-price .price-value {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}

.plan-option-price .price-period {
    font-size: 13px;
    color: #888;
}

.plan-option-features {
    font-size: 13px;
    color: #888;
    margin-top: 4px;
}

/* PayPal Notice */
.paypal-notice {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: #2a2520;
    border: 1px solid #f59e0b33;
    border-radius: 8px;
    margin-bottom: 20px;
}

.paypal-notice svg {
    color: #f59e0b;
    flex-shrink: 0;
    margin-top: 2px;
}

.paypal-notice p {
    color: #f59e0b;
    font-size: 14px;
    margin: 0;
}

/* Proration Info */
.proration-info {
    padding: 12px 16px;
    background: #1a1a1a;
    border-radius: 8px;
    margin-bottom: 20px;
}

.proration-info p {
    color: #888;
    font-size: 13px;
    margin: 0;
}

/* Modal Actions */
.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-actions button {
    min-width: 120px;
}

/* ============================================
   CANCEL SUBSCRIPTION MODAL
   ============================================ */
.cancel-sub-modal {
    width: 480px;
    max-width: 95vw;
}

.cancel-warning {
    text-align: center;
    padding: 20px 0;
}

.cancel-warning svg {
    color: #f59e0b;
    margin-bottom: 16px;
}

.cancel-warning p {
    font-size: 16px;
    color: #ececf1;
    margin: 0;
}

.cancel-details {
    background: #1a1a1a;
    border-radius: 20px;
    padding: 16px;
    margin-bottom: 20px;
}

.cancel-details p {
    font-size: 14px;
    color: #888;
    margin: 0 0 8px 0;
}

.cancel-details p:last-child {
    margin-bottom: 0;
}

.cancel-details strong {
    color: #ececf1;
}

.downgrade-option {
    background: #1a2a1a;
    border: 1px solid #10b98133;
    border-radius: 20px;
    padding: 16px;
    margin-bottom: 20px;
    text-align: center;
}

.downgrade-option p {
    color: #10b981;
    font-size: 14px;
    margin: 0 0 12px 0;
}

.btn-danger {
    background: #ef4444;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 9999px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background: #dc2626;
}

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

/* Responsive */
@media (max-width: 600px) {
    .change-plan-modal,
    .cancel-sub-modal {
        width: 95%;
    }

    .plan-option-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .plan-option-price {
        text-align: left;
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-actions button {
        width: 100%;
    }

    .paid-actions {
        flex-direction: column;
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast {
    background: #1e1e1e;
    border-left: 4px solid;
    border-radius: 9999px;
    padding: 16px 20px;
    min-width: 300px;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s;
}

.toast.success {
    border-left-color: #10b981;
}

.toast.success .toast-icon {
    color: #10b981;
}

.toast.error {
    border-left-color: #ef4444;
}

.toast.error .toast-icon {
    color: #ef4444;
}

.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.toast-message {
    color: #ececf1;
    font-size: 14px;
    line-height: 1.5;
    flex: 1;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Mobile responsive toast */
@media (max-width: 768px) {
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }

    .toast {
        min-width: auto;
        max-width: none;
    }
}

/* ========================================
   CSP-Compliant Utility Classes
   (Replaces inline styles for CSP nonce implementation)
   ======================================== */

/* Display utilities */
.hidden {
    display: none;
}

.inline-block {
    display: inline-block;
}

/* Text alignment utilities */
.text-center {
    text-align: center;
}

/* Margin utilities */
.mt-30 {
    margin-top: 30px;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 2rem;
}

.m-0 {
    margin: 0;
}

.mt-4 {
    margin-top: 4rem;
}

.mt-2 {
    margin-top: 2rem;
}

.mt-1 {
    margin-top: 1rem;
}

/* Flexbox utilities */
.flex-row {
    display: flex;
}

.flex-center {
    display: flex;
    justify-content: center;
}

.flex-wrap {
    flex-wrap: wrap;
}

.flex-gap-1 {
    gap: 1rem;
}

/* Link styling */
.link-primary {
    color: #ECECF1; /* White to match app theme */
    text-decoration: none;
}

.link-primary:hover {
    text-decoration: underline;
    color: #ffffff; /* Brighter white on hover */
}

.link-large {
    font-size: 1.125rem;
    font-weight: 500;
}

/* Checklist styles (for safety.html) */
.checklist {
    list-style: none;
    padding-left: 0;
}

.checklist-item {
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
    position: relative;
}

.checklist-icon {
    position: absolute;
    left: 0;
    font-weight: 700;
}

.checklist-icon-check {
    color: #10b981;
}

.checklist-icon-x {
    color: #ef4444;
}

.checklist-item-muted {
    color: var(--text-secondary);
}

.checklist-icon-bullet {
    color: var(--accent-primary);
}

/* Button utilities */
.cta-button-inline {
    display: inline-block;
    text-decoration: none;
    padding: 14px 32px;
}

/* Color utilities */
.text-muted {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Section utilities */
.company-details {
    margin-top: 2rem;
}

/* =============================================================================
   SUCCESS TOAST NOTIFICATION
   ============================================================================= */

.success-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    color: white;
    padding: 12px 24px;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 10001;
    box-shadow: 0 4px 20px rgba(5, 150, 105, 0.4);
    animation: slideDown 0.3s ease;
    font-weight: 500;
    font-size: 14px;
}

.success-toast.hidden {
    display: none;
}

.success-toast .success-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

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

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
    to {
        transform: translateX(-50%) translateY(-100%);
        opacity: 0;
    }
}