/* Modals */
.search-nav { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--surface-color); color: var(--text-main); border: 1px solid var(--border-color); border-radius: 25px; display: flex; align-items: center; padding: 5px 15px; gap: 10px; z-index: 2000; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.search-nav.hidden { display: none; }
.nav-btn { background: none; border: none; color: var(--text-main); font-size: 18px; cursor: pointer; min-height: 44px; min-width: 44px; display: flex; align-items: center; justify-content: center; }
#search-count { font-size: 14px; min-width: 60px; text-align: center; }

.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); z-index: 3000; display: flex; align-items: flex-end; justify-content: center; opacity: 1; transition: opacity 0.2s; }
.modal.hidden { display: none; opacity: 0; pointer-events: none; }
.modal-content { 
    background: var(--surface-color); color: var(--text-main); width: 100%; 
    height: auto; max-height: 90vh; /* V20: Adjusted height */
    border-radius: 24px 24px 0 0; display: flex; flex-direction: column; 
    overflow: hidden; animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1); 
}
#merge-confirm-modal { align-items: center; }
#merge-confirm-modal .modal-content {
    border-radius: 24px;
    margin: auto;
    width: 90%;
    max-width: 400px;
    height: auto;
    animation: fadeInScale 0.3s ease;
}
@keyframes fadeInScale { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
.modal-content.fullscreen { height: 100vh; max-height: 100vh; border-radius: 0; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px; border-bottom: 1px solid var(--border-color); background: var(--surface-color); z-index: 10; font-weight: 600; font-size: 18px; }
.close-btn { background: var(--border-color); border-radius: 50%; border: none; width: 30px; height: 30px; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-main); }
.modal-list { flex: 1; overflow-y: auto; padding: 0; -webkit-overflow-scrolling: touch; }
.modal-list-item { padding: 15px 20px; border-bottom: 1px solid var(--border-color); cursor: pointer; transition: background 0.1s; display: flex; flex-direction: column;}
.modal-list-item:active { background: var(--surface-hover); }
.search-hit-sender { font-size: 12px; color: var(--primary-color); margin-bottom: 6px; font-weight: bold; }
.search-hit-text { font-size: 14px; color: var(--text-main); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; }

/* Tooltip */
.longpress-tooltip { position: fixed; background: rgba(0,0,0,0.8); color: white; padding: 8px 14px; border-radius: 8px; font-size: 13px; z-index: 5000; pointer-events: none; box-shadow: 0 4px 12px rgba(0,0,0,0.15); transform: translate(-50%, -120%); white-space: nowrap; opacity: 1; transition: opacity 0.2s; font-family: monospace; }
.longpress-tooltip.hidden { opacity: 0; pointer-events: none; }

/* Context Menu & Kebab Menu */
.dropdown-menu {
    position: absolute; top: 55px; right: 10px; background: var(--surface-color); border: 1px solid var(--border-color);
    border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); z-index: 5000; display: flex; flex-direction: column;
    overflow: hidden; min-width: 160px; animation: fadeIn 0.15s ease;
}
.dropdown-item { 
    padding: 12px 16px; font-size: 14px; display: flex; align-items: center; gap: 12px; 
    cursor: pointer; transition: background 0.2s; color: var(--text-main); 
}
.dropdown-item:active { background: var(--surface-hover); }
.dropdown-item svg { width: 18px; height: 18px; }
.dropdown-item span { color: #000; font-weight: 500; }
[data-theme="dark"] .dropdown-item span { color: #fff; } /* Override if dark */

#context-menu {
    position: fixed; background: var(--surface-color); border: 1px solid var(--border-color); border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15); min-width: 160px; z-index: 6000; overflow: hidden; padding: 5px 0;
    display: none; flex-direction: column; top: 0; left: 0; opacity: 0; transition: opacity 0.2s ease, transform 0.1s ease;
    transform: scale(0.95);
}
#context-menu.active { display: flex; opacity: 1; transform: scale(1); }
.context-item { padding: 14px 20px; font-size: 15px; color: var(--text-main); cursor: pointer; display: flex; align-items: center; gap: 12px; transition: background 0.1s; }
.context-item:active { background: var(--surface-hover); }
.context-item.danger { color: var(--delete-bg); }

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

/* Toast */
.toast {
    position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(100px);
    background: var(--text-main); color: var(--bg-color); padding: 12px 24px; border-radius: 24px;
    font-size: 14px; font-weight: 500; z-index: 9999; box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s; opacity: 0; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; pointer-events: all; }

/* V18 Loading Spinner */
#loading-overlay:not(.hidden) {
    display: flex !important;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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