* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
/* --- Account/Profile Modal Two-Pane --- */
.account-modal{max-width:960px;width:100%}
.account-layout{display:flex;gap:1.25rem}
.account-sidebar{width:260px;border-right:1px solid var(--border-light);padding-right:1rem}
.account-sidebar-user{display:flex;gap:.75rem;align-items:center;margin-bottom:1rem}
.account-sidebar-user .avatar-sm{width:40px;height:40px;border-radius:50%;overflow:hidden;background:var(--bg-tertiary);display:flex;align-items:center;justify-content:center;font-weight:600}
.account-sidebar-user .user-meta .name{font-weight:600}
.account-sidebar-user .user-meta .email{font-size:var(--text-sm);color:var(--text-secondary)}
/* ChatGPT-Style Profile Modal - Clean 2-Column Design */
.profile-modal-container {
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 768px;
    width: 90vw;
    max-height: 80vh;
    display: flex;
    overflow: hidden;
    border: 1px solid var(--border-light);
    position: relative;
}

.profile-modal-left {
    width: 200px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.profile-modal-header {
    padding: 1.5rem 1rem 1rem;
    border-bottom: 1px solid var(--border-light);
}

.profile-modal-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    text-align: center;
}

/* Close button positioned on overlay (top-right) */
.profile-close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.profile-close-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-medium);
}

.profile-close-btn svg {
    width: 18px;
    height: 18px;
}

.account-menu {
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
    gap: 2px;
}

.account-menu .menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.15s ease;
    width: 100%;
    text-align: left;
}

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

.account-menu .menu-item.active {
    background: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.account-menu .menu-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.account-menu .menu-item.active svg {
    opacity: 1;
}

.profile-modal-right {
    flex: 1;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0; /* Ensure it can shrink */
}

.profile-tab {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.profile-tab.active {
    display: block;
}

.account-section {
    width: 100%;
    max-width: 100%;
}

.section-title {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
}

.section-title svg {
    display: none; /* Hide icons for cleaner look */
}

.section-title h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* Clean 2-Column Field Layout - No Borders */
.account-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem 2rem;
    margin-bottom: 1.5rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.field .label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.field .value {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 400;
    line-height: 1.5;
    padding: 0;
    background: transparent;
    border: none;
    word-break: break-word;
}

/* Single Column Layout for Forms */
.stack {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.stack .field {
    max-width: 400px;
}

.actions-row {
    display: flex;
    gap: 0.75rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-light);
}

.form-control, #languageSelect {
    width: 100%;
    padding: 0.75rem 0.875rem;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all 0.15s ease;
    font-family: inherit;
}

.form-control:focus, #languageSelect:focus {
    outline: none;
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px rgba(31, 31, 31, 0.1);
}

/* Clean ChatGPT-Style Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-medium);
}

.btn-primary {
    background: var(--text-primary);
    color: var(--bg-primary);
    border-color: var(--text-primary);
}

.btn-primary:hover {
    background: var(--text-secondary);
    border-color: var(--text-secondary);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--border-light);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
    color: var(--danger);
}

.btn svg {
    width: 16px;
    height: 16px;
}

/* Security Tab Specific Styling */
.security-info {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.security-info p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}
.account-content{flex:1;min-width:0}
.account-grid .field .value{font-weight:600}
.section-title{display:flex;align-items:center;gap:.5rem;margin:0 0 .75rem}
.stack{display:flex;flex-direction:column;gap:.5rem}
.actions-row{display:flex;gap:.5rem;margin-top:.75rem}

/* --- Modern GPT-Style Profile Modal --- */
.profile-overlay {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.profile-modal-container {
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 1200px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.profile-sidebar {
    width: 320px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.profile-sidebar-header {
    padding: 2rem 1.5rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.profile-user-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.profile-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

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

.profile-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-email {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-nav {
    flex: 1;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.profile-nav-section {
    padding: 0 1rem;
}

.profile-nav-section:not(:last-child) {
    margin-bottom: 2rem;
}

.profile-nav-bottom {
    margin-top: auto;
    border-top: 1px solid var(--border-light);
    padding-top: 1rem;
}

.profile-nav-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s ease;
    margin-bottom: 0.25rem;
    width: 100%;
    text-align: left;
}

.profile-nav-item:hover {
    background: var(--bg-tertiary);
}

.profile-nav-item.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

.profile-nav-item.danger {
    color: var(--danger);
}

.profile-nav-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.nav-item-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

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

.nav-item-title {
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 0.125rem;
    line-height: 1.3;
}

.nav-item-desc {
    font-size: 0.75rem;
    opacity: 0.7;
    line-height: 1.3;
}

.profile-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.profile-content-header {
    padding: 2rem 2rem 1rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.profile-header-title h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.25rem;
}

.profile-header-title p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

.profile-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.profile-close-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.profile-content-body {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.profile-panel {
    display: none;
}

.profile-panel.active {
    display: block;
}

.profile-section {
    margin-bottom: 2rem;
}

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

.profile-section-header {
    margin-bottom: 1.5rem;
}

.profile-section-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.5rem;
}

.profile-section-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

.profile-detail-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.detail-avatar-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.detail-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 1.5rem;
}

.detail-avatar-info h4 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.25rem;
}

.detail-avatar-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

.profile-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.info-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.info-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
}

.preferences-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-select {
    padding: 0.75rem;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    max-width: 300px;
}

.form-help {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid transparent;
    text-decoration: none;
    background: none;
}

.btn-primary {
    background: var(--text-primary);
    color: var(--bg-primary);
    border-color: var(--text-primary);
}

.btn-primary:hover {
    background: var(--text-secondary);
    border-color: var(--text-secondary);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-light);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border-light);
}

.btn-outline:hover {
    background: var(--bg-tertiary);
}

.security-grid {
    display: grid;
    gap: 1.5rem;
}

.security-item {
    display: flex;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 12px;
}

.security-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.security-content {
    flex: 1;
}

.security-content h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.5rem;
}

.security-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0 0 1rem;
}

/* Responsive Design for Clean Profile Modal */
@media (max-width: 768px) {
    .profile-overlay {
        padding: 1rem;
        align-items: stretch;
    }
    
    .profile-modal-container {
        flex-direction: column;
        max-height: 90vh;
        width: 95vw;
        max-width: none;
    }
    
    .profile-modal-left {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
        flex-shrink: 0;
    }
    
    .profile-modal-header {
        padding: 1rem;
    }
    
    .account-menu {
        flex-direction: row;
        overflow-x: auto;
        padding: 0.5rem 1rem;
        gap: 0.5rem;
    }
    
    .account-menu .menu-item {
        flex-shrink: 0;
        white-space: nowrap;
        min-width: 100px;
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .profile-tab {
        padding: 1.5rem 1.25rem;
    }
    
    .account-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stack .field {
        max-width: none;
    }
    
    .profile-close-btn {
        top: 0.75rem;
        right: 0.75rem;
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 480px) {
    .profile-overlay {
        padding: 0.5rem;
    }
    
    .profile-modal-container {
        width: 100vw;
        max-height: 95vh;
        border-radius: 8px;
    }
    
    .profile-tab {
        padding: 1rem;
    }
    
    .section-title h3 {
        font-size: 1.125rem;
    }
}
    
    .profile-sidebar {
        width: 100%;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
    }
    
    .profile-nav {
        flex-direction: row;
        overflow-x: auto;
        padding: 1rem;
    }
    
    .profile-nav-section {
        display: flex;
        gap: 0.5rem;
        padding: 0;
        margin-bottom: 0;
    }
    
    .profile-nav-bottom {
        margin-left: auto;
        border-top: none;
        border-left: 1px solid var(--border-light);
        padding-top: 0;
        padding-left: 1rem;
    }
    
    .profile-content-header {
        padding: 1.5rem;
    }
    
    .profile-content-body {
        padding: 1.5rem;
    }
    
    .profile-info-grid {
        grid-template-columns: 1fr;
    }
    
    .nav-item-desc {
        display: none;
    }
}

/* Global utility classes */
.hidden {
    display: none !important;
}

:root {
    --kb-inset: 0px; /* Dynamic bottom inset for Android Chrome keyboard/nav */
    --input-h: 120px; /* Dynamic input container height */
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    font-weight: var(--font-weight-normal);
    line-height: var(--leading-normal);
    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh; /* Account for browser UI on mobile */
}

/* Sidebar Styles - ChatGPT/LibreChat Monochrome with Collapse */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: none;
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
}

/* Sidebar collapsed state for desktop */
.sidebar.collapsed {
    width: 60px;
}

.sidebar.collapsed ~ .main-content {
    margin-left: 60px;
}

/* Global modular sidebar toggle states */
.module-page-sidebar-collapsed .main-content {
    margin-left: 60px !important;
    transition: margin-left 0.3s ease !important;
}

.module-page-sidebar-expanded .main-content {
    margin-left: 260px !important;
    transition: margin-left 0.3s ease !important;
}

/* Ensure main content has proper transition on module pages */
.module-page-active .main-content {
    transition: margin-left 0.3s ease !important;
}

.sidebar.collapsed .sidebar-content,
.sidebar.collapsed .sidebar-footer {
    opacity: 0;
    pointer-events: none;
}

.sidebar.collapsed .sidebar-new-chat {
    padding: 0 12px 16px 12px;
    justify-content: center;
}

.sidebar.collapsed .new-chat-btn {
    width: 40px;
    justify-content: center;
}

.sidebar.collapsed .sidebar-toggle-btn svg {
    transform: rotate(180deg);
}

.sidebar-header {
    padding: 16px 12px;
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}


.logo h2 {
    font-family: var(--font-serif);
    color: var(--text-primary);
    font-size: var(--text-xl);
    margin-bottom: calc(8px + env(safe-area-inset-bottom) + var(--kb-inset));
    font-weight: var(--font-weight-bold);
    letter-spacing: var(--tracking-tight);
    line-height: var(--leading-tight);
}

.new-chat-btn {
    width: 40px;
    height: 40px;
    padding: 10px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-sans);
    box-shadow: none;
}

.new-chat-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Sidebar Toggle Button - ChatGPT Style */
.sidebar-toggle-btn {
    width: 40px;
    height: 40px;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-sans);
    flex-shrink: 0;
}

.sidebar-toggle-btn svg {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-toggle-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Mobile Sidebar Toggle */
.mobile-sidebar-toggle {
    width: 40px;
    height: 40px;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    display: none;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
}

.mobile-sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.sidebar-section {
    margin-bottom: 20px;
}

.sidebar-section h3 {
    color: var(--text-tertiary);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    margin: 0 0 12px 12px;
    font-weight: var(--font-weight-semibold);
    opacity: 0.8;
    font-family: var(--font-sans);
}

.category-list,
.recent-chats,
.submenu {
    list-style: none;
    padding-left: 0;
}

.category-list li,
.submenu li {
    list-style: none;
    list-style-type: none;
}

.category-item,
.chat-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-weight: var(--font-weight-medium);
    letter-spacing: var(--tracking-normal);
}

.category-item:hover,
.chat-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.category-item.active,
.chat-item.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: var(--font-weight-semibold);
    box-shadow: none;
}

/* Ensure links inside category items maintain styling */
.category-item a {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    width: 100%;
    height: 100%;
}

.category-item:hover a,
.category-item.active a {
    color: inherit;
}

/* Submenu Styles - Ultra Thinking Compact Navigation */
.category-item.has-submenu {
    display: flex;
    flex-direction: column;
}

.category-item.has-submenu .category-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.submenu-arrow {
    transition: transform 0.3s ease;
    margin-left: auto;
    flex-shrink: 0;
}

.category-item.has-submenu.active .submenu-arrow {
    transform: rotate(90deg);
}

.submenu {
    display: none;
    margin: 4px 0 0 10px;
    padding: 0;
    list-style: none;
    width: calc(100% - 20px);
    clear: both;
}

.submenu.active {
    display: block;
}

.submenu-item {
    margin: 0;
    padding: 0;
    list-style: none;
}

.submenu-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    border-radius: 4px;
    transition: all 0.2s ease;
    margin: 1px 0;
    line-height: 1.2;
    width: 100%;
    box-sizing: border-box;
}

.submenu-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.submenu-link i {
    width: 14px !important;
    height: 14px !important;
    flex-shrink: 0;
    opacity: 0.7;
}

.submenu-link:hover i {
    color: var(--text-primary);
}

/* Ensure submenu text doesn't wrap and fits in sidebar */
.submenu-link span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.chat-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--text-sm);
    font-weight: normal;
}

/* Clean chat link styles - match category text */
.chat-link {
    display: block;
    color: inherit;
    text-decoration: none;
    padding: 0;
    transition: all 0.2s ease;
}

.chat-link:hover {
    color: inherit;
    text-decoration: none;
}

.chat-link:has(.chat-count) {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-count {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    font-weight: normal;
    opacity: 0.7;
}

.sidebar-footer {
    padding: 8px;
    border-top: none;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: none;
    transition: all 0.1s ease;
    margin: 4px;
    box-shadow: var(--shadow-light);
}

.user-avatar {
    width: 20px;
    height: 20px;
    background: #10a37f;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: white;
    font-weight: 600;
    overflow: hidden;
}

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

.user-details {
    flex: 1;
}

.user-name {
    font-size: var(--text-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    letter-spacing: var(--tracking-normal);
}

.user-status {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    font-weight: var(--font-weight-normal);
    letter-spacing: var(--tracking-wide);
}

.user-menu-btn {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.1s;
    font-size: 16px;
}

.user-menu-btn:hover {
    background: #f3f4f6;
    color: #2d333a;
}

/* Login Section */
.login-section {
    padding: 8px;
    margin: 4px;
}

.login-btn {
    width: 100%;
    padding: 12px 16px;
    background: var(--text-primary);
    color: var(--text-inverse);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: var(--font-weight-semibold);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-sans);
    justify-content: center;
    box-shadow: var(--shadow-light);
}

.login-btn:hover {
    background: var(--text-secondary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.login-btn:active {
    transform: translateY(0);
}

.google-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Profile Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-dark);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: var(--text-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin: 0;
    font-family: var(--font-sans);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

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

.modal-body {
    padding: 24px;
}

.profile-info {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.profile-avatar {
    width: 48px;
    height: 48px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: var(--text-primary);
    color: var(--text-inverse);
    font-weight: var(--font-weight-semibold);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

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

.profile-details {
    flex: 1;
}

.profile-name {
    font-size: var(--text-base);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin-bottom: 4px;
    font-family: var(--font-sans);
}

.profile-email {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-family: var(--font-sans);
}

.profile-actions {
    display: flex;
    justify-content: flex-end;
}

.logout-btn {
    padding: 10px 16px;
    background: var(--text-primary);
    color: var(--text-inverse);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: var(--font-weight-medium);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-sans);
}

.logout-btn:hover {
    background: var(--text-secondary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.logout-btn:active {
    transform: translateY(0);
}

/* Main Content Styles */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    position: relative;
    margin-left: 260px;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-primary);
    backdrop-filter: none;
    position: sticky;
    top: 0;
    z-index: 5;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    justify-content: flex-start;
}

/* Header logo styling moved to fonts.css */

.chat-header h1 {
    font-family: var(--font-sans);
    font-size: var(--text-lg);
    color: var(--text-primary);
    font-weight: var(--font-weight-semibold);
    letter-spacing: var(--tracking-tight);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: var(--leading-tight);
    text-align: center;
    flex: 1;
}

/* Legacy sidebar toggle - now hidden */
.sidebar-toggle {
    display: none;
}

/* Remove legacy hover */
/* .sidebar-toggle:hover removed */

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 32px 24px;
    padding-bottom: calc(var(--input-h) + env(safe-area-inset-bottom) + var(--kb-inset) + 24px);
    background: var(--bg-primary);
    scroll-behavior: smooth;
}

.welcome-message {
    text-align: center;
    padding: 80px 32px 40px 32px;
    max-width: 800px;
    margin: 0 auto;
    animation: fadeIn 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.welcome-icon {
    font-size: 72px;
    margin-bottom: 32px;
    opacity: 0.8;
    color: var(--text-primary);
    filter: none;
    animation: float 4s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
        opacity: 0.8;
    }
    50% {
        transform: translateY(-12px);
        opacity: 0.9;
    }
}

.welcome-message h2 {
    font-family: var(--font-sans);
    color: var(--text-primary);
    font-size: clamp(2rem, 5vw, 3.5rem);
    margin-bottom: 24px;
    font-weight: var(--font-weight-bold);
    letter-spacing: var(--tracking-tighter);
    line-height: var(--leading-tight);
}

.welcome-message p {
    color: var(--text-secondary);
    font-size: var(--text-xl);
    line-height: var(--leading-relaxed);
    font-weight: var(--font-weight-normal);
    letter-spacing: var(--tracking-normal);
    max-width: 600px;
    margin: 0 auto;
}

/* ChatGPT-style Big Welcome - Remove Colored Background */
.martus-greeting {
    text-align: center;
    padding: 0 24px 40px 24px;
    max-width: 700px;
    margin: 0 auto;
}

.martus-greeting .greeting-content {
    background: transparent;
    border-radius: none;
    padding: 0;
    box-shadow: none;
    animation: fadeInScale 0.8s ease-out 0.2s both;
}

.martus-greeting .greeting-content p {
    color: var(--text-tertiary);
    font-size: var(--text-lg);
    line-height: var(--leading-relaxed);
    margin: 0 0 16px 0;
    font-weight: var(--font-weight-normal);
    letter-spacing: var(--tracking-normal);
}

.martus-greeting .greeting-content strong {
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    text-shadow: none;
}

/* Subtle animation for greeting */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message {
    display: flex;
    margin-bottom: 32px;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: var(--font-sans);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
        filter: blur(2px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    margin-right: 16px;
    flex-shrink: 0;
    font-weight: var(--font-weight-semibold);
    overflow: hidden;
    transition: all 0.2s ease;
}

/* User avatar styles - monochrome */
.user-avatar {
    border: 1px solid var(--border-light);
    background: var(--text-primary);
    color: var(--text-inverse);
    box-shadow: var(--shadow-light);
}

.user-avatar .avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* AI avatar styles - monochrome */
.ai-avatar {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    font-size: 18px;
    box-shadow: var(--shadow-light);
}

/* Server-side rendered content styles - make headings look like regular messages */
.ssr-message .question-heading {
    font-family: inherit;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
    margin: 0;
    padding: 0;
    color: inherit;
}

.ssr-message .answer-content {
    font-family: inherit;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
    margin: 0;
    padding: 0;
    color: inherit;
}

/* Hide SSR content when JavaScript loads (client-side takes over) */
.js-loaded .ssr-message {
    display: none;
}

/* Bible Study Section Styles */
.bible-study-section {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #ffffff;
}

.bible-controls {
    padding: 20px 24px;
    border-bottom: 1px solid #e5e5e5;
    background: #f9f9f9;
}

.bible-selector-row {
    display: flex;
    gap: 20px;
    align-items: end;
}

.bible-language-selector,
.bible-version-selector,
.bible-book-selector,
.bible-chapter-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bible-language-selector {
    flex: 1;
}

.bible-version-selector {
    flex: 2;
}

.bible-book-selector {
    flex: 2;
}

.bible-chapter-selector {
    flex: 1;
}

.bible-controls label {
    font-weight: 600;
    color: #2d333a;
    font-size: 14px;
}

.bible-controls select {
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: white;
    color: #2d333a;
    font-size: 16px;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.bible-controls select:focus {
    outline: none;
    border-color: #10a37f;
    box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

.bible-controls select:disabled {
    background: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}


/* Language/Version Section */
.bible-language-version-section {
    transition: all 0.3s ease;
    overflow: hidden;
}

/* Book/Chapter Section */
.bible-book-chapter-section {
    /* Always visible */
}

/* Floating Bible Reading Controls */
.bible-reading-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.bible-content:hover .bible-reading-controls {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Mobile Bible Reading Controls */
@media (max-width: 768px) {
    .bible-reading-controls {
        position: fixed;
        top: auto;
        bottom: 150px;
        right: 20px;
        left: 20px;
        width: auto;
        justify-content: center;
        z-index: 100;
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(12px);
    }
}

.reading-controls-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    white-space: nowrap;
}

.control-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #ffffff;
    color: #374151;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.control-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    transform: scale(1.05);
}

.control-btn:active {
    background: #f3f4f6;
    border-color: #6b7280;
    transform: scale(0.98);
}

.control-icon {
    line-height: 1;
}

.reading-controls-separator {
    width: 1px;
    height: 20px;
    background: #e5e7eb;
}

.bible-content {
    flex: 1;
    padding: 20px 24px;
    padding-bottom: 120px; /* Reserve space for sticky input */
    position: relative; /* For absolute positioning of controls */
    overflow-y: auto;
    line-height: 1.8;
}

.bible-placeholder {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}

.bible-placeholder .bible-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.bible-placeholder h3 {
    color: #2d333a;
    margin-bottom: calc(8px + env(safe-area-inset-bottom) + var(--kb-inset));
    font-weight: 600;
}

/* Bible Content Wrapper - 2 Column Layout */
.bible-content-wrapper {
    display: flex;
    gap: 20px;
    height: 100%;
    overflow: hidden;
    padding-bottom: 180px; /* Space for sticky chat-input-container */
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
}

/* Desktop: Left/Right Layout */
.bible-content {
    flex: 1;
    min-width: 0; /* Allow flex item to shrink */
    position: relative;
    overflow-y: auto;
    padding: 0 12px 20px 0;
}

.bible-thinking-panel {
    flex: 1;
    min-width: 0; /* Allow flex item to shrink */
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 20px;
    position: relative;
    overflow-y: auto;
    display: none; /* Hide by default until Bible content is loaded */
}

/* Bible Chapter Content */
.bible-chapter-content {
    max-width: none; /* Remove max-width for 2-column layout */
    margin: 0;
    padding-bottom: 40px; /* Reduced padding since content is now in columns */
}

/* Thinking Panel Header */
.thinking-panel-header {
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.thinking-panel-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 5px 0;
    color: var(--text-primary);
}

.thinking-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

/* Thinking Content */
.thinking-content {
    line-height: 1.6;
    font-size: 15px;
}

.thinking-placeholder {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.thinking-icon {
    font-size: 32px;
    margin-bottom: 15px;
}

/* Thinking Loading State */
.thinking-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.thinking-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-light);
    border-top: 3px solid var(--text-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}



/* Thinking Error State */
.thinking-error {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.error-icon {
    font-size: 32px;
    margin-bottom: 15px;
}

.retry-btn {
    background: var(--text-primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    margin-top: 10px;
    transition: background-color 0.2s ease;
}

.retry-btn:hover {
    background: var(--text-secondary);
}

/* Thinking Stream Content */
.thinking-stream-content {
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Mobile: Single Column Scrollable Layout */
@media (max-width: 768px) {
    .bible-content-wrapper {
        flex-direction: column;
        gap: 8px; /* Reduce gap between content and thinking panel */
        height: auto; /* Allow natural height */
        padding-bottom: 120px; /* Space for sticky input */
        width: 100%;
        box-sizing: border-box;
        overflow: visible;
    }
    
    .bible-thinking-panel {
        max-height: none; /* Remove height constraint */
        overflow-y: visible; /* Remove internal scrolling, use main scroll */
        order: 2; /* Show thinking panel below Bible content on mobile */
        width: 100%;
        margin: 0;
        flex-shrink: 0;
        padding: 16px; /* Reduce padding on mobile */
    }
    
    .bible-content {
        max-height: none; /* Remove height constraint */
        overflow-y: visible; /* Allow natural scrolling */
        width: 100%;
        margin: 0;
        padding: 0 20px 8px 0; /* Reduce bottom padding */
        box-sizing: border-box;
    }
    
    .bible-chapter-content {
        padding-bottom: 8px; /* Minimal padding on mobile for tight layout */
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Mobile Bible Content Toggle */
    .bible-mobile-toggle-container {
        display: none; /* Hidden by default until thinking panel is available */
        position: fixed;
        bottom: 120px; /* Above chat input */
        left: 50%;
        transform: translateX(-50%);
        z-index: 1000;
        padding: 0 20px;
        width: 100%;
        box-sizing: border-box;
    }
    
    .bible-content-toggle {
        display: flex;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        border: 1px solid #e9ecef;
        border-radius: 12px;
        padding: 4px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
        max-width: 280px;
        margin: 0 auto;
    }
    
    .toggle-option {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 12px 16px;
        border: none;
        border-radius: 8px;
        background: transparent;
        color: #6c757d;
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    
    .toggle-option.active {
        background: #007bff;
        color: white;
        box-shadow: 0 2px 4px rgba(0, 123, 255, 0.3);
    }
    
    .toggle-option:not(.active):hover {
        background: #f8f9fa;
        color: #495057;
    }
    
    .toggle-option i {
        width: 16px;
        height: 16px;
    }
    
    /* Mobile toggle will be shown via JavaScript when thinking panel is available */
    
    /* Mobile book selector label - show "Sách:" instead of "Sách Kinh Thánh:" */
    .bible-book-selector label {
        font-size: 0; /* Hide original text */
    }
    
    .bible-book-selector label::after {
        content: "Sách:";
        font-size: 14px; /* Restore font size */
        font-weight: 500;
        color: #495057;
    }
}

.bible-chapter-content h1 {
    color: #2d333a;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
}

.bible-verse {
    margin-bottom: 12px;
    padding: 8px 0;
}

.bible-verse-number {
    background: #6b7280;
    color: white;
    font-weight: 600;
    font-size: 12px;
    padding: 2px 6px;
    margin-right: 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 20px;
    text-align: center;
    line-height: 1.2;
}

.bible-verse-text {
    color: #2d333a;
    font-size: 16px;
    line-height: 1.6;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    /* Chat Container Mobile Layout - Allow scrolling when Bible section is shown */
    .chat-container {
        overflow: visible; /* Allow scrolling on mobile */
    }
    
    /* Bible Study Section Mobile Layout */
    .bible-study-section {
        width: 100%;
        height: auto; /* Allow natural height */
        overflow: visible; /* Allow scrolling */
        flex-direction: column;
    }
    
    /* Bible Controls Mobile Layout */
    .bible-controls {
        padding: 16px 20px;
        width: 100%;
        box-sizing: border-box;
    }
    
    
    /* Hide language/version section by default on mobile */
    .bible-language-version-section {
        max-height: 0;
        margin-bottom: 0;
        opacity: 0;
        overflow: hidden;
        transition: all 0.3s ease;
    }
    
    /* Show language/version section when expanded */
    .bible-language-version-section.expanded {
        max-height: 200px;
        margin-bottom: 16px;
        opacity: 1;
    }
    
    /* Keep book/chapter on single row on mobile */
    .bible-book-chapter-section .bible-selector-row {
        flex-direction: row;
        gap: 12px;
        width: 100%;
    }
    
    .bible-book-selector,
    .bible-chapter-selector {
        flex: 1;
        min-width: 0; /* Allow flex items to shrink */
    }
    
    /* Language/version in column on mobile when expanded */
    .bible-language-version-section .bible-selector-row {
        flex-direction: column;
        gap: 16px;
        width: 100%;
    }
    
    .bible-language-selector,
    .bible-version-selector {
        flex: none;
        width: 100%;
    }
    
    /* Ensure selects are properly sized on mobile */
    .bible-controls select {
        width: 100%;
        box-sizing: border-box;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Mobile specific selector improvements */
    .bible-selector-row {
        flex-wrap: nowrap;
        overflow: hidden;
    }
}
    
    .bible-content {
        padding: 16px 20px;
        padding-bottom: calc(100px + env(safe-area-inset-bottom) + var(--kb-inset)); /* Reserve space for sticky input + safe area + keyboard inset */
    }
    
    /* Mobile reading controls */
    .bible-reading-controls {
        position: fixed;
        top: auto;
        bottom: 20px;
        right: 20px;
        left: 20px;
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        justify-content: center;
        padding: 8px 12px;
        border-radius: 20px;
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    }
    
    .control-label {
        font-size: 11px;
    }
    
    .control-btn {
        width: 36px;
        height: 36px;
        font-size: 11px;
    }
}

/* Deep Study Button Styles - Monochrome */
.deep-study-container {
    margin-top: 12px;
    text-align: left;
    border-top: 1px solid var(--border-light);
    padding-top: 12px;
}

.deep-study-btn {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: var(--text-sm);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: var(--shadow-light);
    font-family: var(--font-sans);
}

.deep-study-btn:hover {
    background: var(--bg-tertiary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
    border-color: var(--border-medium);
}

.deep-study-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-light);
    background: var(--bg-quaternary);
}

/* Thinking Response Styles */
.thinking-response {
    background: #f8faff;
    border-left: 4px solid #667eea;
}

.thinking-header {
    color: #667eea;
    font-size: 14px;
    margin-bottom: calc(8px + env(safe-area-inset-bottom) + var(--kb-inset));
    padding-bottom: calc(8px + env(safe-area-inset-bottom) + var(--kb-inset));
    border-bottom: 1px solid #e2e8f0;
}

.thinking-indicator {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #667eea;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

.message-content {
    flex: 1;
    background: transparent;
    padding: 16px 0;
    border-radius: 12px;
    position: relative;
    border: none;
    box-shadow: none;
    font-family: var(--font-sans);
}

/* User messages get background and right alignment */
.user-message {
    flex-direction: row-reverse;
    justify-content: flex-end;
    margin-left: auto;
    max-width: 85%;
    margin-bottom: 24px;
}

.user-message .message-content {
    background: var(--bg-chat-user);
    border: none;
    max-width: fit-content;
    margin-left: auto;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: var(--shadow-light);
}

.user-message .message-avatar {
    margin-right: 0;
    margin-left: 16px;
}

/* AI messages have no background and left alignment */
.ai-message {
    justify-content: flex-start;
    max-width: 100%;
    margin-bottom: 28px;
}

.ai-message .message-content {
    background: transparent;
    border: none;
    padding: 16px 0;
    line-height: var(--leading-relaxed);
}

.message-content p {
    line-height: var(--leading-relaxed);
    margin: 0 0 0.75em 0;
    color: var(--text-primary);
    font-weight: var(--font-weight-normal);
    font-size: var(--text-base);
    letter-spacing: var(--tracking-normal);
}

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

.chat-input-container {
    padding: 24px 24px 32px 24px;
    background: var(--bg-primary);
    border-top: none;
    position: sticky;
    bottom: 0;
    z-index: 10;
    padding-bottom: calc(32px + env(safe-area-inset-bottom) + var(--kb-inset));
    backdrop-filter: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ChatGPT-style Welcome Mode - Hide real input */
.welcome-mode .chat-input-container {
    display: none;
}

.welcome-mode .chat-messages {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 200px);
}

/* ChatGPT Welcome Content */
.chatgpt-welcome {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
    opacity: 1;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.welcome-content {
    padding: 40px 24px;
}

.welcome-avatar {
    width: 64px;
    height: 64px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 32px auto;
    color: var(--text-secondary);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.welcome-title {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    margin: 0 0 24px 0;
    letter-spacing: var(--tracking-tight);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.welcome-question {
    font-family: var(--font-sans);
    font-size: 1.5rem;
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    margin: 0 0 32px 0;
    line-height: 1.3;
    letter-spacing: var(--tracking-normal);
}

.welcome-subtitle {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    color: var(--text-secondary);
    line-height: var(--leading-relaxed);
    max-width: 480px;
    margin: 0 auto 40px auto;
    letter-spacing: var(--tracking-normal);
}

/* Welcome Input Container - Uses single input system */
.welcome-input-container {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 24px;
}

.welcome-input-wrapper .input-wrapper {
    /* When input-wrapper is moved inside welcome-input-wrapper, ensure it has proper styling */
    margin: 0 auto;
    max-width: 640px;
}

.input-wrapper {
    position: relative;
    max-width: 768px;
    margin: 0 auto;
    background: var(--bg-primary);
    border: 2px solid var(--border-light);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

/* Contenteditable Virtual Input Area */
.message-input-editable {
    width: 100%;
    min-height: 112px; /* Double the original 56px */
    max-height: none; /* Allow unlimited expansion */
    padding: 16px 16px 55px 16px;
    border: none;
    outline: none;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background: transparent;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow: hidden; /* No scrolling */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: block; /* Use block for proper contenteditable behavior */
    box-sizing: border-box; /* Ensure padding is included in width calculation */
}

/* Specific styling for messageInput ID */
#messageInput {
    text-align: left;
}

/* Placeholder styling for contenteditable */
.message-input-editable:empty:before {
    content: attr(data-placeholder);
    color: var(--text-tertiary);
    font-weight: var(--font-weight-normal);
    letter-spacing: var(--tracking-normal);
    pointer-events: none;
}

.message-input-editable:focus:empty:before {
    opacity: 0.6;
}

.input-wrapper:hover {
    border-color: var(--border-medium);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.08);
}

.input-wrapper:focus-within {
    border-color: var(--text-primary);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12), 0 0 0 3px rgba(31, 31, 31, 0.08);
}

.send-button {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: var(--text-primary);
    color: var(--text-inverse);
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    pointer-events: none;
}

.send-button.enabled {
    opacity: 1;
    pointer-events: auto;
    background: var(--text-primary);
}

.send-button.enabled:hover {
    background: var(--accent-hover);
    opacity: 1;
}

.send-button.enabled:active {
    opacity: 0.8;
}

/* Input Icon Buttons - ChatGPT/LibreChat Style */
.attach-button {
    position: absolute;
    left: 16px;
    bottom: 16px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.attach-button:hover {
    background: var(--border-light);
    color: var(--text-primary);
}

.input-actions {
    position: absolute;
    right: 12px;
    bottom: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.voice-button {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.voice-button:hover {
    background: var(--border-light);
    color: var(--text-primary);
}

.voice-button.recording {
    background: #ef4444;
    color: white;
}

.voice-button.recording:hover {
    background: #dc2626;
}

/* Updated send button for new layout */
.send-button {
    position: relative;
    top: auto;
    right: auto;
    transform: none;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: var(--text-primary);
    color: var(--text-inverse);
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    pointer-events: none;
}

.send-button:hover {
    background: var(--accent-hover);
    opacity: 1;
}

.send-button:active {
    opacity: 0.8;
}

.typing-indicator {
    display: flex;
    align-items: center;
    margin-bottom: 32px;
    opacity: 0.8;
}

.typing-dots {
    background: var(--bg-tertiary);
    padding: 12px 16px;
    border-radius: 16px;
    display: flex;
    gap: 6px;
    margin-left: 52px;
    margin-bottom: 20px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-tertiary);
    border-radius: 50%;
    animation: typing 1.6s infinite ease-in-out;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: scale(0.75) translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: scale(1) translateY(-2px);
        opacity: 1;
    }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    /* Prevent horizontal overflow and ensure consistent width */
    body, html {
        overflow-x: hidden;
        width: 100%;
        max-width: 100%;
    }
    
    .app-container {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }
    
    .main-content {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
        margin-left: 0;
    }
    
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: var(--shadow-dark);
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .mobile-sidebar-toggle {
        display: flex;
    }
    
    .chat-header {
        padding: 20px 16px 12px 16px; /* More top space on mobile */
    }
    
    .chat-messages {
        padding: 16px;
        /* Slightly shorter message area to avoid 3-button nav overlap */
        /* padding-bottom: calc(0px + env(safe-area-inset-bottom) + var(--kb-inset) + 24px); */
    }
    
    .chat-input-container {
        padding: 16px;
       /*  padding-bottom: calc(0px + env(safe-area-inset-bottom));  */
       /* More space to clear 3-button nav */
        position: sticky;
        bottom: 0px;
        z-index: 10;
    }
    
    /* Mobile Welcome Mode - Hide real input */
    .welcome-mode .chat-input-container {
        display: none;
    }
    
    .welcome-title {
        font-size: 2rem;
    }
    
    .welcome-question {
        font-size: 1.25rem;
    }
    
    .welcome-content {
        padding: 32px 16px;
    }
    
    .welcome-input-container {
        padding: 0 16px;
    }
    
    .input-wrapper {
        margin: 0;
    }
    
    .input-wrapper {
        border-radius: 12px;
    }

    .message-input-editable {
        min-height: 88px; /* Slightly smaller on mobile but still double */
        padding: 14px 14px 50px 14px;
        font-size: var(--text-sm);
    }
    
    .attach-button {
        left: 12px;
        bottom: 12px;
        width: 28px;
        height: 28px;
    }
    
    .input-actions {
        right: 8px;
        bottom: 8px;
        gap: 2px;
    }
    
    .voice-button, .send-button {
        width: 28px;
        height: 28px;
    }
    
    .welcome-message {
        padding: 32px 16px;
    }
    
    .welcome-message h2 {
        font-size: 24px;
    }
    
    .martus-greeting {
        padding: 16px;
        margin: 0 auto -10px auto;
    }
    
    .martus-greeting .greeting-content {
        padding: 16px 20px;
    }
    
    .martus-greeting .greeting-content p {
        font-size: 15px;
    }
}

/* Scrollbar Styling - Monochrome */
.sidebar-content::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.sidebar-content::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 2px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--border-dark);
}

/* Streaming message cursor animation - Monochrome */
.cursor {
    animation: blink 1.2s infinite;
    color: var(--text-primary);
    font-weight: var(--font-weight-semibold);
}

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

.message.streaming {
    opacity: 0.9;
}

/* Related Questions Formatting */
.related-questions-formatted {
    margin-top: 24px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #10a37f;
}

.related-questions-formatted h4 {
    margin: 0 0 12px 0;
    color: #374151;
    font-size: 16px;
    font-weight: 600;
}

.related-questions-formatted ul {
    margin: 0;
    padding-left: 20px;
    list-style-type: disc;
}

.related-questions-formatted li {
    margin: 8px 0;
    color: #4b5563;
    line-height: 1.5;
}

.related-questions-formatted li:hover {
    color: #10a37f;
    cursor: pointer;
}

.clickable-question {
    transition: all 0.2s ease;
    border-radius: 4px;
    padding: 2px 4px;
    margin: 2px 0;
}

.clickable-question:hover {
    background-color: #e6f7f0;
    color: #0d9764 !important;
    cursor: pointer;
    text-decoration: underline;
}

/* Deep Study Thinking Response */
.thinking-response {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin: 16px 0;
}

.thinking-content {
    padding: 16px 20px;
    margin: 0;
}

.thinking-header {
    color: #10a37f;
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: calc(8px + env(safe-area-inset-bottom) + var(--kb-inset));
}

.message.thinking-response {
    display: block;
    width: 100%;
    max-width: none;
}

/* Reasoning Phase Styles (DeepSeek R1 Thinking) */
.reasoning-section {
    background: #f8f9ff;
    border: 1px solid #e1e5f1;
    border-radius: 8px;
    margin: 12px 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.reasoning-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px 16px;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
}

.reasoning-toggle {
    font-size: 12px;
    transition: transform 0.3s ease;
    min-width: 12px;
}

.reasoning-section:not(.collapsed) .reasoning-toggle {
    transform: rotate(90deg);
}

.reasoning-count {
    margin-left: auto;
    opacity: 0.8;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
}

.reasoning-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.reasoning-section:not(.collapsed) .reasoning-content,
.reasoning-section.expanded .reasoning-content {
    max-height: 300px;
    overflow-y: auto;
}

.reasoning-text {
    margin: 0;
    padding: 16px;
    background: transparent;
    border: none;
    font-family: var(--font-sans);
    font-size: 13px;
    line-height: 1.5;
    color: #4a5568;
    white-space: pre-wrap;
    word-break: break-word;
}

.phase-indicator {
    font-size: 12px;
    color: #10a37f;
    font-weight: normal;
    opacity: 0.8;
}

/* Deep Study Article Spacing - Reduced spacing for better readability */
.deep-study-article {
    line-height: 1.6;
}

.deep-study-article h1,
.deep-study-article h2,
.deep-study-article h3,
.deep-study-article h4 {
    margin: 18px 0 12px 0;
}

.deep-study-article h1:first-child,
.deep-study-article h2:first-child,
.deep-study-article h3:first-child,
.deep-study-article h4:first-child {
    margin-top: 0;
}

.deep-study-article p {
    margin: 12px 0;
}

.deep-study-article ul,
.deep-study-article ol {
    margin: 12px 0;
    padding-left: 24px;
}

.deep-study-article li {
    margin: 6px 0;
}

.deep-study-article .related-questions-formatted {
    margin: 18px 0 12px 0;
    padding: 14px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #10a37f;
}

.deep-study-article .related-questions-formatted h4 {
    margin: 0 0 10px 0;
    color: #10a37f;
}

.deep-study-article .related-questions-formatted ul {
    margin: 0;
}

.deep-study-article .related-questions-formatted li {
    margin: 4px 0;
}

/* Deep Study Button */
.deep-study-container {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
}

/* Removed duplicate - using monochrome version */

/* Removed duplicate - using monochrome version */

.deep-study-btn:active {
    transform: translateY(0);
}

/* Thinking Response Styles */
.thinking-response {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin: 16px 0;
    overflow: hidden;
}

.thinking-content {
    padding: 16px 20px;
    margin: 0;
}

.thinking-header {
    color: #10a37f;
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: calc(8px + env(safe-area-inset-bottom) + var(--kb-inset));
    display: flex;
    align-items: center;
    gap: 8px;
}

.message.thinking-response {
    display: block;
    width: 100%;
    max-width: none;
    margin: 16px 0;
}

.phase-indicator {
    font-size: 12px;
    color: #10a37f;
    opacity: 0.8;
    font-weight: normal;
}

/* Reasoning Section Styles (OpenRouter Thinking) */
.reasoning-section {
    background: #f8f9ff;
    border: 1px solid #e1e5f1;
    border-radius: 8px;
    margin: 12px 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.reasoning-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px 16px;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
}

.reasoning-toggle {
    font-size: 12px;
    transition: transform 0.3s ease;
    min-width: 12px;
}

.reasoning-section:not(.collapsed) .reasoning-toggle {
    transform: rotate(90deg);
}

.reasoning-count {
    margin-left: auto;
    opacity: 0.8;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
}

.reasoning-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.reasoning-section:not(.collapsed) .reasoning-content,
.reasoning-section.expanded .reasoning-content {
    max-height: 300px;
    overflow-y: auto;
}

.reasoning-text {
    margin: 0;
    padding: 16px;
    background: transparent;
    border: none;
    font-family: var(--font-sans);
    font-size: 13px;
    line-height: 1.5;
    color: #4a5568;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Streaming animation for thinking */
.thinking-response.streaming .thinking-header::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10a37f;
    margin-left: 8px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* Chat History Page Styles */
.chat-history-section {
    flex-direction: column;
    height: 100%;
    background: #ffffff;
    padding: 2rem 0;
    align-items: center;
    overflow: hidden;
}

.history-container {
    width: 100%;
    max-width: 800px;
    padding: 0 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: 0; /* Allow flexbox shrinking */
}

.history-header {
    flex-shrink: 0; /* Don't shrink the header */
    margin-bottom: 2rem;
}

.history-header h1 {
    font-size: 2.5rem;
    color: #2d333a;
    margin: 0;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.history-content {
    width: 100%;
    max-width: 600px;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
    flex: 1; /* Take up remaining space */
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Prevent overflow */
    min-height: 0; /* Allow flexbox shrinking */
}

.history-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: #6b7280;
}

.loading-icon {
    font-size: 2rem;
    animation: spin 2s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.history-loading p {
    font-size: 1.1rem;
    color: #6b7280;
}

.history-search-container {
    width: 100%;
    max-width: 600px;
    padding: 0 20px 2rem 20px;
    flex-shrink: 0; /* Don't shrink the search container */
}

.search-input-wrapper {
    display: flex;
    gap: 0.5rem;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 0.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: border-color 0.2s ease;
}

.search-input-wrapper:focus-within {
    border-color: #10a37f;
}

.search-input-wrapper input {
    flex: 1;
    border: none;
    outline: none;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    background: transparent;
    color: #2d333a;
}

.search-input-wrapper input::placeholder {
    color: #9ca3af;
}

.search-input-wrapper button {
    background: #10a37f;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.search-input-wrapper button:hover {
    background: #0d8f73;
}

.load-more-btn {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    color: #374151;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.load-more-btn:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}

/* Mobile responsiveness for chat history */
@media (max-width: 768px) {
    .chat-history-section {
        padding: 1rem 0;
    }
    
    .history-header h1 {
        font-size: 1.8rem;
        margin-bottom: 1.5rem;
    }
    
    .history-content {
        padding: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .history-container {
        padding: 0 15px;
    }
    
    .history-search-container {
        padding: 0 15px 1.5rem 15px;
    }
    
    .history-list {
        padding-right: 4px; /* Smaller scrollbar space on mobile */
    }
}

/* Chat History Items */
.history-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto; /* Make the list scrollable */
    flex: 1; /* Take up remaining space */
    padding-right: 8px; /* Space for scrollbar */
}

/* Custom scrollbar for history list */
.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    transition: all 0.2s ease;
}

.history-item:hover {
    border-color: #10a37f;
    box-shadow: 0 2px 8px rgba(16, 163, 127, 0.1);
}

.history-item-content {
    flex: 1;
    text-align: left;
}

.history-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2d333a;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.history-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
    color: #6b7280;
}

.history-date {
    color: #9ca3af;
}

.history-category {
    color: #10a37f;
    font-weight: 500;
}

.history-open-btn {
    background: #10a37f;
    border: none;
    border-radius: 6px;
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

.history-open-btn:hover {
    background: #0d8f73;
}

/* History states */
.history-empty, .history-error, .history-login-prompt {
    text-align: center;
    color: #6b7280;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1; /* Take up remaining space */
    min-height: 300px; /* Minimum height for centered content */
}

.history-empty .empty-icon,
.history-error .error-icon,
.history-login-prompt .login-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.history-empty h3,
.history-error h3,
.history-login-prompt h3 {
    color: #2d333a;
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.history-empty p,
.history-error p,
.history-login-prompt p {
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.start-chat-btn, .retry-btn, .history-login-btn {
    background: #10a37f;
    border: none;
    border-radius: 8px;
    color: white;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.start-chat-btn:hover, .retry-btn:hover, .history-login-btn:hover {
    background: #0d8f73;
}

/* Mobile styles for history items */
@media (max-width: 768px) {
    .history-item {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
        padding: 1rem;
        cursor: pointer; /* Make the whole item clickable */
    }
    
    .history-item:active {
        background: #f3f4f6;
        transform: scale(0.98);
    }
    
    .history-meta {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .history-open-btn {
        display: none; /* Hide the button on mobile */
    }
    
    .history-title {
        cursor: pointer;
        color: #10a37f; /* Make it look clickable */
        font-weight: 600;
    }
}

/* Message Action Buttons - Monochrome ChatGPT Style */
.message-actions {
    display: flex !important;
    align-items: center;
    gap: 4px !important;
    margin-top: 12px !important;
    opacity: 1;
}

.message-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: 8px;
    padding: 0;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.message-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

.message-action-btn svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
    transition: stroke 0.15s ease;
}

/* Dark mode support - Monochrome */
@media (prefers-color-scheme: dark) {
    .message-action-btn {
        color: var(--text-tertiary);
    }
    
    .message-action-btn:hover {
        background: var(--bg-hover);
        color: var(--text-primary);
    }
}



/* Mobile adjustments - Keep consistent with desktop */
@media (max-width: 768px) {
    .message-actions {
        opacity: 1; /* Always visible on mobile */
        gap: 4px !important; /* Keep same gap as desktop */
        margin-top: 8px !important; /* Slightly smaller top margin for mobile */
    }
    
    .message-action-btn {
        width: 32px; /* Same as desktop */
        height: 32px; /* Same as desktop */
        border-radius: 6px; /* Ensure consistent border radius */
    }
    
    .message-action-btn svg {
        width: 16px; /* Same as desktop */
        height: 16px; /* Same as desktop */
        stroke-width: 2; /* Ensure consistent stroke width */
    }
    
    /* Improve touch targets without changing visual size */
    .message-action-btn {
        position: relative;
        min-width: 44px; /* iOS minimum touch target */
        min-height: 44px; /* iOS minimum touch target */
    }
    
    .message-action-btn::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 44px;
        height: 44px;
        border-radius: 8px;
        z-index: -1;
    }
}

/* Debug Interface Styles */
.debug-container {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.debug-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.debug-header h2 {
    font-size: 28px;
    margin-bottom: 8px;
    font-weight: 600;
}

.debug-header p {
    font-size: 16px;
    opacity: 0.9;
}

.debug-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.debug-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e5e5;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.debug-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.debug-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #2d333a;
    display: flex;
    align-items: center;
    gap: 8px;
}

.debug-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.info-row:nth-child(even) {
    background: #ffffff;
}

.label {
    font-weight: 500;
    color: #495057;
    font-size: 14px;
}

.value {
    font-family: var(--font-mono);
    font-size: 13px;
    color: #007bff;
    font-weight: 500;
    word-break: break-all;
    max-width: 60%;
}

.debug-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.debug-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    background: #007bff;
    color: white;
}

.debug-btn:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.debug-btn:active {
    transform: translateY(0);
}

.debug-logs {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e5e5;
}

.debug-logs h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #2d333a;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logs-container {
    max-height: 300px;
    overflow-y: auto;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
    border: 1px solid #e9ecef;
}

.log-entry {
    font-family: var(--font-mono);
    font-size: 12px;
    color: #495057;
    margin-bottom: 4px;
    padding: 4px 8px;
    background: white;
    border-radius: 4px;
    border-left: 3px solid #007bff;
}

.log-time {
    color: #6c757d;
    font-weight: 500;
}

/* Responsive adjustments for debug interface */
@media (max-width: 768px) {
    .debug-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .debug-container {
        padding: 15px;
    }
    
    .debug-header {
        margin-bottom: 20px;
        padding: 15px;
    }
    
    .debug-header h2 {
        font-size: 24px;
    }
    
    .debug-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .debug-btn {
        justify-content: center;
    }
    
    .info-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .value {
        max-width: 100%;
        word-break: break-word;
    }
}

@media (max-width: 480px) {
    .debug-card {
        padding: 15px;
    }
    
    .debug-card h3 {
        font-size: 16px;
    }
    
    .label, .value {
        font-size: 12px;
    }
}

/* Bible Language/Version Overlay Modal */
.bible-language-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.bible-language-overlay.show {
    display: flex;
    opacity: 1;
}

.bible-overlay-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.bible-overlay-modal {
    position: relative;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 450px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.bible-language-overlay.show .bible-overlay-modal {
    transform: scale(1);
}

.bible-overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 16px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
}

.bible-overlay-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #2d333a;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bible-overlay-close {
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    transition: all 0.2s ease;
}

.bible-overlay-close:hover {
    background: #e9ecef;
    color: #495057;
}

.bible-overlay-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.bible-overlay-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bible-overlay-selector label {
    font-weight: 500;
    color: #495057;
    font-size: 14px;
}

.bible-overlay-selector select {
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    color: #495057;
    transition: border-color 0.2s ease;
}

.bible-overlay-selector select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.bible-overlay-footer {
    padding: 16px 24px 20px;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.bible-overlay-apply {
    background: #007bff;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bible-overlay-apply:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.bible-overlay-apply:active {
    transform: translateY(0);
}

/* Language trigger button styling */
.bible-language-trigger-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 0 0 auto;
}

.bible-language-trigger {
    background: white;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #495057;
    font-weight: 500;
    min-height: 48px;
    box-sizing: border-box;
}

.bible-language-trigger:hover {
    border-color: #007bff;
    color: #007bff;
}

.bible-language-trigger:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* Mobile responsive adjustments for overlay */
@media (max-width: 768px) {
    .bible-overlay-modal {
        width: 95%;
        margin: 20px;
    }
    
    .bible-overlay-header {
        padding: 16px 20px 12px;
    }
    
    .bible-overlay-header h3 {
        font-size: 16px;
    }
    
    .bible-overlay-content {
        padding: 20px;
        gap: 16px;
    }
    
    .bible-overlay-footer {
        padding: 12px 20px 16px;
    }
    
    .bible-overlay-apply {
        padding: 10px 20px;
        font-size: 13px;
    }
    
    .bible-language-trigger {
        padding: 12px;
        min-width: 48px;
        justify-content: center;
    }
    
    .bible-language-trigger .language-text {
        display: none;
    }
}

@media (max-width: 480px) {
    .bible-overlay-modal {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }
    
    .bible-overlay-header {
        padding: 14px 16px 10px;
    }
    
    .bible-overlay-content {
        padding: 16px;
        flex: 1;
        overflow-y: auto;
    }
    
    .bible-overlay-footer {
        padding: 10px 16px 14px;
    }
}

/* Hidden utility class */
.hidden {
    display: none;
}
