        /* CSS Variables for Consistency */
        :root {
            --color-bg-primary: #0f172a;
            --color-bg-glass: rgba(15, 23, 42, 0.7);
            --color-text-primary: #f8fafc;
            --color-text-muted: #94a3b8;
            --color-accent: #6366f1;
            --color-accent-hover: #a855f7;
            --spacing-unit: 8px;
            --border-radius-sm: 12px;
            --border-radius-md: 16px;
            --border-radius-lg: 24px;
            --transition-fast: 0.2s;
            --transition-normal: 0.3s;
        }

        /* Reduced Motion Support */
        @media (prefers-reduced-motion: reduce) {

            *,
            *::before,
            *::after {
                animation-duration: 0.01ms !important;
                animation-iteration-count: 1 !important;
                transition-duration: 0.01ms !important;
            }
        }

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

        body {
            background: var(--color-bg-primary);
            color: var(--color-text-primary);
            font-family: 'Outfit', 'Inter', -apple-system, sans-serif;
            overflow-x: hidden;
        }

        /* Focus Visible for Keyboard Navigation */
        *:focus-visible {
            outline: 3px solid var(--color-accent);
            outline-offset: 2px;
            border-radius: 4px;
        }

        /* Skip to Content Link */
        .skip-to-content {
            position: absolute;
            top: -40px;
            left: 0;
            background: var(--color-accent);
            color: white;
            padding: 8px 16px;
            text-decoration: none;
            border-radius: 0 0 8px 0;
            z-index: 10000;
            font-weight: 600;
        }

        .skip-to-content:focus {
            top: 0;
        }

        /* Offline Banner */
        .offline-banner {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
            color: white;
            padding: 12px 24px;
            text-align: center;
            font-weight: 600;
            z-index: 9999;
            transform: translateY(-100%);
            transition: transform var(--transition-normal);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        }

        .offline-banner.show {
            transform: translateY(0);
        }

        /* Keyboard Shortcut Hint */
        .keyboard-hint {
            position: fixed;
            bottom: 100px;
            right: 24px;
            background: rgba(0, 0, 0, 0.8);
            backdrop-filter: blur(10px);
            color: white;
            padding: 12px 16px;
            border-radius: var(--border-radius-sm);
            font-size: 14px;
            opacity: 0;
            transform: translateY(20px);
            transition: all var(--transition-normal);
            pointer-events: none;
            z-index: 1000;
        }

        .keyboard-hint.show {
            opacity: 1;
            transform: translateY(0);
        }

        .kbd {
            background: rgba(255, 255, 255, 0.1);
            padding: 2px 8px;
            border-radius: 4px;
            font-family: monospace;
            font-size: 12px;
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        .app-container {
            height: 100vh;
            height: 100dvh;
            display: flex;
            flex-direction: column;
            padding-bottom: calc(80px + env(safe-area-inset-bottom));
        }

        .top-header {
            background: rgba(15, 23, 42, 0.7);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            padding: 20px 24px;
            padding-top: calc(20px + env(safe-area-inset-top));
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid rgba(255, 255, 255, 0.05);
            position: sticky;
            top: 0;
            z-index: 2000;
        }

        .logo {
            font-size: 28px;
            font-weight: 800;
            background: linear-gradient(135deg, #a855f7 0%, #6366f1 50%, #3b82f6 100%);
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
            letter-spacing: -1px;
        }

        .tab-content {
            flex: 1;
            min-height: 0;
            overflow-y: auto;
            overflow-x: hidden;
            -webkit-overflow-scrolling: touch;
            scroll-behavior: smooth;
            position: relative;
        }

        /* Tab panes: only the one matching data-active is visible */
        .tab-content .tab-pane {
            display: none !important;
            visibility: hidden !important;
            position: absolute !important;
            left: -9999px !important;
            width: 100%;
            pointer-events: none !important;
        }

        .tab-content[data-active="home"] #home-tab,
        .tab-content[data-active="scan"] #scan-tab {
            display: block !important;
            visibility: visible !important;
            position: relative !important;
            left: 0 !important;
            pointer-events: auto !important;
        }

        @keyframes slideInUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .bottom-nav {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            background: rgba(15, 23, 42, 0.8);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border-top: 1px solid rgba(255, 255, 255, 0.05);
            display: flex;
            padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
            box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.4);
            z-index: 3000;
        }

        .nav-item {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 6px;
            padding: 8px;
            cursor: pointer;
            border: none;
            background: none;
            color: #94a3b8;
            transition: all 0.3s;
        }

        .nav-item.active {
            color: #6366f1;
            transform: translateY(-4px);
        }

        .nav-icon {
            font-size: 24px;
            transition: transform 0.3s;
        }

        .nav-item.active .nav-icon {
            transform: scale(1.2);
            filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.5));
        }

        .nav-label {
            font-size: 11px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        /* HOME TAB */
        .vault-status {
            background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(168, 85, 247, 0.1) 100%);
            border: 1px solid rgba(255, 255, 255, 0.1);
            padding: 24px;
            border-radius: 24px;
            margin-bottom: 24px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
        }

        .vault-status.locked {
            background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(220, 38, 38, 0.1) 100%);
            border-color: rgba(239, 68, 68, 0.2);
        }

        .scans-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 12px;
            padding-bottom: 80px;
        }

        @media (min-width: 768px) {
            .scans-grid {
                grid-template-columns: repeat(4, 1fr);
                gap: 20px;
            }
        }

        .scan-card {
            background: linear-gradient(135deg, rgba(30, 41, 59, 0.6) 0%, rgba(15, 23, 42, 0.8) 100%);
            border: 1px solid rgba(99, 102, 241, 0.2);
            border-radius: 20px;
            overflow: hidden;
            cursor: pointer;
            transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
            position: relative;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        }

        .scan-card:hover,
        .scan-card:active {
            transform: translateY(-8px) scale(1.02);
            border-color: rgba(99, 102, 241, 0.5);
            box-shadow: 0 16px 40px rgba(99, 102, 241, 0.2), 0 0 0 1px rgba(99, 102, 241, 0.3);
        }

        .scan-thumbnail {
            width: 100%;
            aspect-ratio: 1;
            position: relative;
            background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
            display: flex;
            align-items: center;
            justify-content: center;
            overflow: hidden;
        }

        .scan-thumbnail img {
            width: 100%;
            height: 100%;
            object-fit: contain;
            transition: transform 0.5s;
            background: #0f172a;
            padding: 4px;
        }

        .scan-card:hover .scan-thumbnail img {
            transform: scale(1.05);
        }

        .delete-btn {
            position: absolute;
            top: 10px;
            right: 10px;
            width: 36px;
            height: 36px;
            border-radius: 12px;
            background: rgba(239, 68, 68, 0.8);
            backdrop-filter: blur(8px);
            border: none;
            color: white;
            font-size: 18px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            z-index: 10;
            opacity: 0;
            transition: all 0.2s;
        }

        .scan-card:hover .delete-btn {
            opacity: 1;
        }

        .scan-info {
            padding: 16px;
            background: rgba(15, 23, 42, 0.8);
            backdrop-filter: blur(10px);
            border-top: 1px solid rgba(99, 102, 241, 0.2);
        }

        .scan-info .md3-label-small {
            color: #94a3b8;
            font-size: 13px;
            font-weight: 500;
            display: flex;
            align-items: center;
            gap: 6px;
        }

        /* 
        .scan-info .md3-label-small::before {
            content: '📅';
            font-size: 14px;
        }
        */

        .scan-info p {
            font-size: 14px;
            font-weight: 600;
            color: #cbd5e1;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        /* SCAN TAB */
        .scan-upload {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 24px;
            padding: 60px 20px;
            text-align: center;
        }

        .upload-btn {
            width: 140px;
            height: 140px;
            border-radius: 40px;
            background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
            border: none;
            color: white;
            font-size: 50px;
            cursor: pointer;
            box-shadow: 0 15px 35px rgba(99, 102, 241, 0.4);
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s;
        }

        .upload-btn:active {
            transform: scale(0.9);
            box-shadow: 0 5px 15px rgba(99, 102, 241, 0.2);
        }

        .scan-preview {
            display: none;
            flex-direction: column;
            gap: 24px;
        }

        .scan-preview.active {
            display: flex;
            padding-bottom: 40px;
            /* Ensure buttons aren't cut off by scroll edge */
        }

        .action-buttons {
            display: flex;
            flex-direction: column;
            gap: 12px;
            width: 100%;
        }

        @media (min-width: 600px) {
            .action-buttons {
                flex-direction: row;
            }

            .action-buttons button {
                flex: 1;
            }
        }

        /* TOOLS TAB */
        .tool-section {
            background: rgba(30, 41, 59, 0.5);
            border-radius: 20px;
            padding: 24px;
            margin-bottom: 20px;
            border: 1px solid rgba(255, 255, 255, 0.05);
        }

        .md3-btn-filled {
            background: linear-gradient(135deg, #6366f1 0%, #3b82f6 100%) !important;
            border-radius: 12px;
            font-weight: 700;
            letter-spacing: 0.5px;
            padding: 12px 24px;
            height: auto;
            box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
        }

        .md3-btn-outlined {
            border-radius: 12px;
            border-color: rgba(255, 255, 255, 0.2) !important;
            color: white !important;
            font-weight: 600;
        }

        .md3-btn-text {
            background: none;
            border: none;
            color: var(--color-accent);
            font-weight: 600;
            padding: 8px 16px;
            border-radius: 12px;
            cursor: pointer;
        }

        .md3-btn-text:hover {
            background: rgba(255, 255, 255, 0.05);
            color: var(--color-accent-hover);
        }

        /* Specific override for Delete button visibility */
        #delete-selected-btn {
            color: #fca5a5 !important;
            /* Bright Pink/Red */
            border-color: rgba(239, 68, 68, 0.5) !important;
        }

        .md3-title-medium {
            font-weight: 800;
            font-size: 20px;
            letter-spacing: -0.5px;
            color: var(--color-text-primary);
        }

        .md3-body-medium {
            color: var(--color-text-muted);
            line-height: 1.6;
            color: var(--color-text-muted);
        }

        .hidden {
            display: none !important;
        }

        /* Recovery Codes Modal */
        .recovery-modal {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.95);
            z-index: 6000;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 24px;
        }

        .recovery-content {
            background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
            border-radius: 24px;
            padding: 32px;
            max-width: 500px;
            width: 100%;
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .recovery-codes-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 12px;
            margin: 24px 0;
        }

        .recovery-code {
            background: rgba(99, 102, 241, 0.1);
            border: 1px solid rgba(99, 102, 241, 0.3);
            padding: 16px;
            border-radius: 12px;
            text-align: center;
            font-family: 'Courier New', monospace;
            font-size: 20px;
            font-weight: 700;
            letter-spacing: 2px;
            color: #6366f1;
        }

        .warning-box {
            background: rgba(239, 68, 68, 0.1);
            border: 1px solid rgba(239, 68, 68, 0.3);
            padding: 16px;
            border-radius: 12px;
            margin: 16px 0;
            color: #fca5a5;
        }

        /* Manual Crop Corner Handles */
        .crop-corner {
            width: 40px;
            height: 40px;
            background: #00ff00;
            border: 3px solid white;
            border-radius: 50%;
            cursor: move;
            box-shadow: 0 0 20px rgba(0, 255, 0, 0.8);
            touch-action: none;
            /* Prevent scrolling while dragging */
            z-index: 10003;
        }

        .crop-corner:active {
            transform: scale(1.2);
            box-shadow: 0 0 30px rgba(0, 255, 0, 1);
        }

        /* Preview Filter Buttons */
        .filter-btn {
            min-width: 80px;
            padding: 12px 16px;
            background: rgba(255, 255, 255, 0.1);
            border: 2px solid rgba(255, 255, 255, 0.2);
            border-radius: 12px;
            color: white;
            cursor: pointer;
            transition: all 0.2s;
            text-align: center;
        }

        .filter-btn:active,
        .filter-btn.active {
            background: rgba(99, 102, 241, 0.3);
            border-color: #6366f1;
            transform: scale(0.95);
        }

        /* Review Modal & Toast */
        .review-tag {
            padding: 8px 16px;
            border-radius: 20px;
            border: 1px solid rgba(255, 255, 255, 0.2);
            background: rgba(255, 255, 255, 0.05);
            color: #e2e8f0;
            font-size: 14px;
            cursor: pointer;
            transition: all 0.2s;
        }

        .review-tag.selected {
            background: #6366f1;
            border-color: #6366f1;
            color: white;
            box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
        }

        @keyframes slideUp {
            from {
                transform: translateY(100%);
                opacity: 0;
            }

            to {
                transform: translateY(0);
                opacity: 1;
            }
        }

        @keyframes toastSlide {
            from {
                transform: translate(-50%, -20px);
                opacity: 0;
            }

            to {
                transform: translate(-50%, 0);
                opacity: 1;
            }
        }

        /* RESPONSIVE IMPROVEMENTS */
        @media (max-width: 600px) {

            /* Adjust padding/size for header buttons to ensure text fits on mobile */
            #export-vault-btn,
            #import-vault-btn,
            #select-mode-btn {
                padding: 8px 12px;
                min-width: auto;
                font-size: 13px !important;
            }
        }

        /* Batch Actions Bar */
        #batch-actions {
            display: flex;
            flex-direction: column;
            gap: 12px;
            background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(168, 85, 247, 0.1) 100%);
            border: 1px solid rgba(99, 102, 241, 0.2);
            padding: 16px;
            border-radius: 16px;
            margin-bottom: 24px;
            /* Increased margin */
        }

        #batch-actions>div {
            display: flex;
            gap: 8px;
            width: 100%;
        }

        #batch-actions button {
            flex: 1;
            /* Full width buttons on mobile */
            white-space: nowrap;
        }

        @media (min-width: 600px) {
            #batch-actions {
                flex-direction: row;
                justify-content: space-between;
                align-items: center;
            }

            #batch-actions>div {
                width: auto;
            }
        }