/* iOS-Style Email Browser */

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

:root {
    --ios-blue: #007AFF;
    --ios-gray-bubble: #E5E5EA;
    --ios-gray-text: #8E8E93;
    --ios-background: #FFFFFF;
    --ios-header-bg: #F7F7F7;
    --ios-separator: #C6C6C8;
    --bubble-radius: 18px;
    --status-bar-height: 44px;
    --iphone-radius: 47px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #000000;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

/* iPhone Frame */
.iphone-frame {
    width: 100%;
    max-width: 400px;
    height: 844px;
    max-height: 80vh;
    background: #000000;
    border-radius: var(--iphone-radius);
    padding: 12px;
    box-shadow: 
        0 0 0 2px #1a1a1a,
        0 0 0 3px #2a2a2a,
        0 20px 60px rgba(0, 0, 0, 0.5),
        inset 0 0 6px rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

/* Status Bar */
.status-bar {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    height: var(--status-bar-height);
    background: var(--ios-background);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1000;
    color: #000000;
    font-size: 15px;
    font-weight: 600;
    border-radius: calc(var(--iphone-radius) - 12px) calc(var(--iphone-radius) - 12px) 0 0;
}

.status-left,
.status-right {
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 2;
}

.status-time {
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.3px;
}

.status-icon {
    opacity: 1;
}

/* Camera Notch */
.status-notch {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 30px;
    background: #000000;
    border-radius: 0 0 20px 20px;
    z-index: 1;
}

/* Battery Icon */
.battery-icon {
    display: flex;
    align-items: center;
    position: relative;
    width: 27px;
    height: 13px;
}

.battery-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 1.5px solid #000000;
    border-radius: 4px;
    opacity: 0.4;
}

.battery-level {
    position: absolute;
    left: 2px;
    top: 2px;
    bottom: 2px;
    width: calc(100% - 6px);
    background: #000000;
    border-radius: 2px;
}

.battery-tip {
    position: absolute;
    right: -3px;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 6px;
    background: #000000;
    border-radius: 0 2px 2px 0;
    opacity: 0.4;
}

/* App Content Container */
.app-content {
    width: 100%;
    height: 100%;
    background: var(--ios-background);
    border-radius: calc(var(--iphone-radius) - 12px);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* View Management */
.view {
    position: absolute;
    top: var(--status-bar-height);
    left: 0;
    width: 100%;
    height: calc(100% - var(--status-bar-height));
    display: none;
    flex-direction: column;
    transition: transform 0.3s ease-out;
}

.view.active {
    display: flex;
}

/* iOS Header */
.ios-header {
    background-color: var(--ios-header-bg);
    padding: 12px 16px;
    border-bottom: 0.5px solid var(--ios-separator);
    flex-shrink: 0;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ios-header h1 {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.4px;
}

.ios-header h2 {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.4px;
}

/* Owner Profile Picture */
.owner-profile-pic {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid var(--ios-blue);
}

.owner-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Conversation Header */
.conversation-header {
    justify-content: flex-start;
    padding-left: 8px;
    gap: 12px;
}

.back-button {
    display: flex;
    align-items: center;
    background: none;
    border: none;
    color: var(--ios-blue);
    font-size: 17px;
    cursor: pointer;
    padding: 8px;
    -webkit-tap-highlight-color: transparent;
}

.back-button:active {
    opacity: 0.5;
}

.conversation-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--ios-gray-text);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}

.conversation-avatar .avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.conversation-avatar .avatar-initials {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    left: 0;
}

/* Search Bar */
.search-bar {
    background-color: var(--ios-header-bg);
    padding: 8px 16px 12px 16px;
    border-bottom: 0.5px solid var(--ios-separator);
    flex-shrink: 0;
}

.search-input-wrapper {
    background-color: rgba(142, 142, 147, 0.12);
    border-radius: 10px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-icon {
    font-size: 16px;
    color: var(--ios-gray-text);
}

.search-input-wrapper input {
    border: none;
    background: none;
    outline: none;
    font-size: 17px;
    width: 100%;
    color: #000000;
}

.search-input-wrapper input::placeholder {
    color: var(--ios-gray-text);
}

.search-input-wrapper input:disabled {
    opacity: 0.6;
}

.search-input-wrapper input.searching {
    color: var(--ios-blue);
}

/* Contact List */
.contact-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* App Footer */
.app-footer {
    padding: 12px 16px;
    text-align: center;
    border-top: 0.5px solid var(--ios-separator);
    background-color: var(--ios-header-bg);
    flex-shrink: 0;
}

.app-footer a {
    color: var(--ios-blue);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
}

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

.contact-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 0.5px solid var(--ios-separator);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.15s;
}

.contact-item:active {
    background-color: rgba(0, 0, 0, 0.05);
}

.contact-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--ios-gray-text);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    flex-shrink: 0;
    margin-right: 12px;
    overflow: hidden;
    position: relative;
}

.contact-avatar .avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.contact-avatar .avatar-initials {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    left: 0;
}

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

.contact-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
    letter-spacing: -0.3px;
}

.contact-preview {
    font-size: 14px;
    color: var(--ios-gray-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
    margin-left: 8px;
}

.contact-time {
    font-size: 13px;
    color: var(--ios-gray-text);
    white-space: nowrap;
}

.contact-badge {
    background-color: var(--ios-blue);
    color: white;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

/* Message Container */
.message-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    background-color: #FFFFFF;
}

/* Date Separator */
.date-separator {
    text-align: center;
    margin: 16px 0;
}

.date-separator span {
    background-color: rgba(142, 142, 147, 0.12);
    color: var(--ios-gray-text);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
}

/* Subject Separator */
.subject-separator {
    text-align: center;
    margin: 12px 0 8px 0;
}

.subject-separator span {
    background-color: rgba(0, 122, 255, 0.08);
    color: var(--ios-blue);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
}

/* Message Bubble */
.message-group {
    margin-bottom: 12px;
}

.message-bubble {
    max-width: 75%;
    margin-bottom: 4px;
    display: flex;
    flex-direction: column;
}

.message-bubble.sent {
    align-items: flex-end;
    margin-left: auto;
}

.message-bubble.received {
    align-items: flex-start;
}

.bubble-content {
    padding: 12px 16px;
    border-radius: var(--bubble-radius);
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    font-size: 17px;
    line-height: 1.4;
    letter-spacing: -0.4px;
    overflow-x: hidden;
    max-width: 100%;
}

.bubble-content a {
    color: inherit;
    text-decoration: underline;
    word-break: break-all;
}

.message-bubble.sent .bubble-content {
    background-color: var(--ios-blue);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-bubble.received .bubble-content {
    background-color: var(--ios-gray-bubble);
    color: #000000;
    border-bottom-left-radius: 4px;
}

.bubble-time {
    font-size: 13px;
    color: var(--ios-gray-text);
    margin-top: 4px;
    padding: 0 4px;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 32px;
    color: var(--ios-gray-text);
    font-size: 15px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 32px;
    color: var(--ios-gray-text);
}

.empty-state h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #000000;
}

.empty-state p {
    font-size: 15px;
}

/* Mobile Optimization */
@media (max-width: 480px) {
    .message-bubble {
        max-width: 85%;
    }
    
    .bubble-content {
        font-size: 16px;
    }
}

/* Responsive adjustments */
@media (max-width: 420px) {
    body {
        padding: 10px;
    }
    
    .iphone-frame {
        max-height: 95vh;
        border-radius: 40px;
        padding: 10px;
    }
    
    .app-content {
        border-radius: 30px;
    }
}

@media (min-height: 900px) {
    .iphone-frame {
        height: 844px;
    }
}

/* Scrollbar Styling (for desktop) */
::-webkit-scrollbar {
    width: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(142, 142, 147, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(142, 142, 147, 0.5);
}

/* Action Sheet Overlay */
.action-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0);
    z-index: 10000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    transition: background-color 0.3s ease;
    pointer-events: all;
}

.action-sheet-overlay.active {
    background-color: rgba(0, 0, 0, 0.4);
}

/* Action Sheet */
.action-sheet {
    background-color: #FFFFFF;
    border-radius: 14px 14px 0 0;
    width: 100%;
    max-width: 400px;
    padding: 8px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.1);
}

.action-sheet-overlay.active .action-sheet.mobile {
    transform: translateY(0);
}

/* Desktop Action Sheet */
.action-sheet.desktop {
    border-radius: 14px;
    width: auto;
    min-width: 200px;
    max-width: 300px;
    transform: scale(0.8);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.action-sheet-overlay.active .action-sheet.desktop {
    transform: scale(1);
    opacity: 1;
}

/* Action Sheet Buttons */
.action-sheet-button {
    background-color: #FFFFFF;
    border: none;
    padding: 16px;
    font-size: 17px;
    font-weight: 500;
    color: var(--ios-blue);
    text-align: center;
    cursor: pointer;
    border-radius: 10px;
    margin: 4px 0;
    transition: background-color 0.15s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.action-sheet-button:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.action-sheet-button:active {
    background-color: rgba(0, 0, 0, 0.1);
}

.action-sheet-button.cancel {
    color: #000000;
    font-weight: 600;
    margin-top: 8px;
}

/* Copy Confirmation */
.copy-confirmation {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    z-index: 1000;
    white-space: nowrap;
}

.copy-confirmation.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Message Bubble cursor hint */
.message-bubble {
    cursor: pointer;
    position: relative;
}

/* Homescreen View */
.homescreen-container {
    width: 100%;
    height: 100%;
    background-image: url('../data/profile_pics/Maxwell_and_Epstein.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px 20px 20px;
}

.homescreen-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 0;
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
    max-width: 350px;
    width: 100%;
    position: relative;
    z-index: 1;
}

.homescreen-footer {
    position: absolute;
    bottom: 40px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
    padding: 0 20px;
}

.homescreen-footer .app-icon {
    opacity: 0.9;
}

.app-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s ease;
}

.app-icon:active {
    transform: scale(0.95);
}

.app-icon-image {
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.app-icon-label {
    font-size: 13px;
    font-weight: 500;
    color: white;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    text-align: center;
    letter-spacing: -0.2px;
}

/* Contacts header with back button */
#contactListView .ios-header {
    justify-content: flex-start;
    padding-left: 8px;
    gap: 12px;
}

#contactListView .ios-header h1 {
    flex: 1;
}

/* Disclaimer Modal */
.disclaimer-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease-out;
}

.disclaimer-modal.hidden {
    display: none;
}

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

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

.disclaimer-card {
    position: relative;
    background: #FFFFFF;
    border-radius: 20px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.disclaimer-header {
    padding: 24px 24px 16px 24px;
    border-bottom: 0.5px solid var(--ios-separator);
    flex-shrink: 0;
}

.disclaimer-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: #000000;
    margin: 0;
    letter-spacing: -0.5px;
}

.disclaimer-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    -webkit-overflow-scrolling: touch;
}

.disclaimer-content p {
    font-size: 16px;
    line-height: 1.6;
    color: #000000;
    margin: 0 0 16px 0;
}

.disclaimer-content h3 {
    font-size: 18px;
    font-weight: 600;
    color: #000000;
    margin: 24px 0 12px 0;
    letter-spacing: -0.4px;
}

.disclaimer-content h3:first-child {
    margin-top: 0;
}

.disclaimer-content a {
    color: var(--ios-blue);
    text-decoration: none;
}

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

.disclaimer-content strong {
    font-weight: 600;
}

.disclaimer-warning {
    background-color: #FFF3CD;
    border-left: 4px solid #FFC107;
    padding: 12px 16px;
    margin: 12px 0;
    border-radius: 8px;
}

.disclaimer-warning p {
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
    color: #856404;
}

.disclaimer-footer {
    padding: 16px 24px;
    border-top: 0.5px solid var(--ios-separator);
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.disclaimer-button {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
}

.disclaimer-button.primary {
    background-color: var(--ios-blue);
    color: white;
}

.disclaimer-button.primary:hover {
    background-color: #0051D5;
}

.disclaimer-button.primary:active {
    transform: scale(0.98);
    background-color: #0051D5;
}

.disclaimer-button.secondary {
    background-color: #FF3B30;
    color: white;
}

.disclaimer-button.secondary:hover {
    background-color: #E6342A;
}

.disclaimer-button.secondary:active {
    transform: scale(0.98);
    background-color: #E6342A;
}

.disclaimer-cancel-warning {
    padding: 12px 24px;
    background-color: #FFE5E5;
    border-top: 0.5px solid #FF3B30;
    text-align: center;
}

.disclaimer-cancel-warning p {
    margin: 0;
    font-size: 15px;
    color: #D32F2F;
    font-weight: 500;
}

/* Mobile adjustments for disclaimer */
@media (max-width: 480px) {
    .disclaimer-modal {
        padding: 10px;
    }
    
    .disclaimer-card {
        max-height: 95vh;
        border-radius: 16px;
    }
    
    .disclaimer-header {
        padding: 20px 20px 12px 20px;
    }
    
    .disclaimer-header h2 {
        font-size: 20px;
    }
    
    .disclaimer-content {
        padding: 20px;
    }
    
    .disclaimer-content p {
        font-size: 15px;
    }
    
    .disclaimer-content h3 {
        font-size: 17px;
    }
    
    .disclaimer-footer {
        padding: 12px 16px;
        flex-direction: column;
    }
    
    .disclaimer-button {
        width: 100%;
    }
}

/* Photos View */
.photos-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background-color: #F2F2F7;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Photos header with back button */
#photosView .ios-header {
    justify-content: flex-start;
    padding-left: 8px;
    gap: 12px;
}

#photosView .ios-header h1 {
    flex: 1;
}

/* Documents View */
.documents-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background-color: #F2F2F7;
}

.document-list {
    padding: 16px;
}

.document-section-header {
    padding: 16px;
    text-align: center;
}

.document-section-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #000000;
    margin: 0 0 4px 0;
    letter-spacing: -0.4px;
}

.section-subtitle {
    font-size: 13px;
    color: var(--ios-gray-text);
    margin: 0;
}

.document-item {
    display: flex;
    align-items: center;
    padding: 16px;
    background-color: #FFFFFF;
    border-radius: 12px;
    margin-bottom: 12px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.1s ease, background-color 0.15s;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.document-item:hover {
    background-color: #F8F8F8;
}

.document-item:active {
    transform: scale(0.98);
    background-color: #F0F0F0;
}

.document-item:last-of-type {
    margin-bottom: 0;
}

.document-icon {
    font-size: 32px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    flex-shrink: 0;
    margin-right: 12px;
}

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

.document-title {
    font-size: 16px;
    font-weight: 600;
    color: #000000;
    margin-bottom: 4px;
    letter-spacing: -0.3px;
    line-height: 1.3;
}

.document-subtitle {
    font-size: 13px;
    color: var(--ios-gray-text);
    font-weight: 500;
}

.document-arrow {
    flex-shrink: 0;
    margin-left: 8px;
    opacity: 0.6;
}

.document-footer {
    margin-top: 24px;
    padding: 16px;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 12px;
}

.document-footer p {
    font-size: 13px;
    color: var(--ios-gray-text);
    margin: 4px 0;
}

.document-footer a {
    color: var(--ios-blue);
    text-decoration: none;
    font-weight: 500;
}

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

.footer-note {
    font-size: 12px !important;
    color: var(--ios-gray-text) !important;
    opacity: 0.8;
}

/* Documents header with back button */
#documentsView .ios-header {
    justify-content: flex-start;
    padding-left: 8px;
    gap: 12px;
}

#documentsView .ios-header h1 {
    flex: 1;
}

/* Lock Screen */
.lock-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    border-radius: var(--iphone-radius);
    overflow: hidden;
}

.lock-screen.hidden {
    display: none;
}

.lock-screen-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    user-select: none;
    pointer-events: none;
}

.lock-icon {
    font-size: 64px;
    animation: lockPulse 2s ease-in-out infinite;
}

@keyframes lockPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }
}

.lock-text {
    font-size: 24px;
    font-weight: 600;
    color: white;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    letter-spacing: -0.5px;
}

.lock-subtext {
    font-size: 18px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    letter-spacing: -0.3px;
}

/* Search Functionality */
.search-results-header {
    padding: 12px 16px 8px 16px;
    background-color: var(--ios-header-bg);
    border-bottom: 0.5px solid var(--ios-separator);
    flex-shrink: 0;
}

.search-results-count {
    font-size: 13px;
    color: var(--ios-gray-text);
    font-weight: 500;
    text-align: center;
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 0.5px solid var(--ios-separator);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.15s;
    background-color: #FFFBF0;
}

.search-result-item:active {
    background-color: rgba(255, 193, 7, 0.1);
}

.search-result-item .contact-info {
    flex: 1;
    min-width: 0;
}

.search-context {
    font-size: 14px;
    color: var(--ios-gray-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    margin-top: 2px;
}

.search-match-count {
    font-size: 12px;
    color: var(--ios-blue);
    font-weight: 500;
    white-space: nowrap;
    background-color: rgba(0, 122, 255, 0.1);
    padding: 2px 6px;
    border-radius: 8px;
}

.clear-search-btn {
    background-color: var(--ios-blue);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 16px;
    transition: background-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
}

.clear-search-btn:hover {
    background-color: #0051D5;
}

.clear-search-btn:active {
    transform: scale(0.98);
    background-color: #0051D5;
}

/* Search term highlighting */
mark {
    background-color: #FFEB3B;
    color: #000000;
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: 500;
}

/* Search target message highlighting */
.message-bubble.search-target {
    position: relative;
}

.message-bubble.search-target::before {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    background-color: rgba(255, 193, 7, 0.3);
    border-radius: calc(var(--bubble-radius) + 4px);
    z-index: -1;
    animation: searchTargetPulse 2s ease-in-out;
}

@keyframes searchTargetPulse {
    0% {
        background-color: rgba(255, 193, 7, 0.6);
        transform: scale(1.02);
    }
    50% {
        background-color: rgba(255, 193, 7, 0.3);
        transform: scale(1);
    }
    100% {
        background-color: rgba(255, 193, 7, 0.1);
        transform: scale(1);
    }
}

/* Search input focus state */
.search-input-wrapper:focus-within {
    background-color: rgba(0, 122, 255, 0.1);
    outline: 2px solid rgba(0, 122, 255, 0.2);
    outline-offset: -1px;
}

.search-input-wrapper:focus-within .search-icon {
    color: var(--ios-blue);
}

/* Search empty state button */
.empty-state .clear-search-btn {
    margin-top: 16px;
    display: inline-block;
}

/* Search Navigation Controls */
.search-navigation-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    background-color: rgba(0, 122, 255, 0.08);
    border-radius: 8px;
    padding: 6px 8px;
}

.search-nav-button {
    background: none;
    border: none;
    color: var(--ios-blue);
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.search-nav-button:hover {
    background-color: rgba(0, 122, 255, 0.1);
}

.search-nav-button:active {
    background-color: rgba(0, 122, 255, 0.2);
    transform: scale(0.95);
}

.search-nav-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.search-nav-indicator {
    font-size: 13px;
    font-weight: 500;
    color: var(--ios-blue);
    white-space: nowrap;
    padding: 0 4px;
    user-select: none;
}

.search-nav-close {
    background: none;
    border: none;
    color: var(--ios-gray-text);
    padding: 4px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    margin-left: 4px;
}

.search-nav-close:hover {
    background-color: rgba(0, 0, 0, 0.08);
    color: #000000;
}

.search-nav-close:active {
    background-color: rgba(0, 0, 0, 0.12);
    transform: scale(0.9);
}

/* Enhanced search highlighting for current result */
.message-bubble.search-current {
    position: relative;
    transform: scale(1.02);
    transition: transform 0.2s ease;
}

.message-bubble.search-current::before {
    content: '';
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.2) 0%, rgba(0, 122, 255, 0.1) 100%);
    border-radius: calc(var(--bubble-radius) + 6px);
    z-index: -1;
    animation: searchCurrentPulse 1.5s ease-in-out infinite;
    border: 2px solid var(--ios-blue);
}

@keyframes searchCurrentPulse {
    0%, 100% {
        opacity: 0.6;
        box-shadow: 0 0 0 0 rgba(0, 122, 255, 0.4);
    }
    50% {
        opacity: 0.8;
        box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
    }
}

.message-bubble.search-current .bubble-content mark {
    background-color: #4CAF50;
    color: white;
    font-weight: 600;
    padding: 2px 4px;
    border-radius: 3px;
    box-shadow: 0 0 0 1px rgba(76, 175, 80, 0.3);
}

/* Responsive adjustments for search navigation */
@media (max-width: 480px) {
    .search-navigation-controls {
        gap: 6px;
        padding: 4px 6px;
    }
    
    .search-nav-indicator {
        font-size: 12px;
        padding: 0 2px;
    }
    
    .search-nav-button {
        padding: 4px;
    }
    
    .conversation-header {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .search-navigation-controls {
        order: 3;
        margin-left: 0;
        flex: 1;
        justify-content: center;
    }
}

/* Ensure conversation header can accommodate search controls */
.conversation-header {
    min-height: 60px;
    align-items: center;
    flex-wrap: nowrap;
}

.conversation-header h2 {
    flex: 1;
    min-width: 0;
    margin-right: 8px;
}

/* Search navigation keyboard shortcuts hint */
.search-navigation-controls[title]::after {
    content: attr(title);
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    white-space: nowrap;
    z-index: 1000;
}

.search-navigation-controls:hover::after {
    opacity: 1;
}
