        :root {
            --primary: #10b981;
            --primary-dark: #059669;
            --app-bg: #f3f4f6;
            --surface: #ffffff;
            --surface-muted: #f9fafb;
            --surface-soft: #f3f4f6;
            --text-primary: #1f2937;
            --text-secondary: #4b5563;
            --text-muted: #6b7280;
            --border: #e5e7eb;
            --modal-bg: #f9fafb;
            --camera-bg: #1f2937;
            --input-bg: #ffffff;
            --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        }

        html[data-theme="dark"] {
            color-scheme: dark;
            --app-bg: #020617;
            --surface: #0f172a;
            --surface-muted: #111827;
            --surface-soft: #1e293b;
            --text-primary: #f8fafc;
            --text-secondary: #cbd5e1;
            --text-muted: #94a3b8;
            --border: #334155;
            --modal-bg: #020617;
            --camera-bg: #020617;
            --input-bg: #111827;
            --shadow-soft: 0 16px 40px rgba(0, 0, 0, 0.35);
        }

        body {
            background-color: var(--app-bg);
            color: var(--text-primary);
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
            min-height: 100vh;
            margin: 0;
        }

        .bg-white,
        header.bg-white,
        .bg-white\/90 {
            background-color: var(--surface) !important;
        }

        .bg-gray-50 {
            background-color: var(--surface-muted) !important;
        }

        .bg-gray-100 {
            background-color: var(--surface-soft) !important;
        }

        .text-gray-800,
        .text-slate-850 {
            color: var(--text-primary) !important;
        }

        .text-gray-700,
        .text-gray-600 {
            color: var(--text-secondary) !important;
        }

        .text-gray-500,
        .text-gray-400 {
            color: var(--text-muted) !important;
        }

        .border-gray-100,
        .border-gray-200 {
            border-color: var(--border) !important;
        }

        input,
        select,
        textarea {
            background-color: var(--input-bg) !important;
            color: var(--text-primary) !important;
            border-color: var(--border) !important;
        }

        input::placeholder {
            color: var(--text-muted);
        }

        * {
            box-sizing: border-box;
        }

        .hidden {
            display: none !important;
        }

        /* Preview Modal Image Fix */
        #previewImage {
            max-width: 100% !important;
            max-height: calc(100vh - 160px) !important;
            width: auto !important;
            height: auto !important;
            object-fit: contain !important;
        }

        #settingsModal > div {
            max-height: calc(100vh - 1.5rem);
        }

        #settingsModal .overflow-y-auto {
            scrollbar-gutter: stable;
            -webkit-overflow-scrolling: touch;
        }

        #resultsModal main {
            scrollbar-gutter: stable;
            -webkit-overflow-scrolling: touch;
        }

        #resultsModal .max-w-2xl > .space-y-4 > .bg-white {
            padding-top: 0.75rem;
            padding-bottom: 0.75rem;
        }

        .result-image-frame {
            position: relative;
            width: 100%;
            height: min(42vh, 300px);
            min-height: 180px;
            max-height: 320px;
            overflow: hidden;
            border-radius: 1rem;
            background: #0f172a;
        }

        .result-image {
            width: 100%;
            height: 100%;
            object-fit: contain;
            display: block;
        }

        @media (min-width: 640px) {
            #settingsModal > div {
                max-height: calc(100vh - 2rem);
            }
        }

        /* Layout Wrapper */
        .app-container {
            display: flex;
            flex-direction: column;
            height: 100dvh; /* dynamic viewport: correct on mobile with collapsible URL bar */
            background-color: var(--app-bg);
            width: 100%;
        }

        /* ═══════════════════════════════════════════
           SCAN VIEWPORT — Premium Scanning HUD
           ═══════════════════════════════════════════ */

        /* Viewport container — fills space between header and bottom of screen (nav floats over) */
        .scan-viewport {
            position: relative;
            width: 100%;
            height: calc(100dvh - var(--header-height, 72px) - var(--nav-height, 64px));
            background: #0a0a0a;
            user-select: none;
            overflow: hidden;
        }

        :root {
            --header-height: 72px; /* ~py-3 py-4 + XP bar */
            --nav-height: 64px;    /* bottom nav bar height */
        }

        @media (min-width: 768px) {
            :root {
                --header-height: 88px;
            }
        }

        .scan-video,
        .scan-image {
            position: absolute;
            inset: 0;
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        /* CTA overlay */
        .scan-cta-panel {
            position: absolute;
            inset: 0;
            z-index: 15;
            display: flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(
                160deg,
                rgba(0, 0, 0, 0.6) 0%,
                rgba(0, 0, 0, 0.3) 50%,
                rgba(0, 0, 0, 0.6) 100%
            );
        }

        .scan-cta-inner {
            text-align: center;
            padding: 1.5rem;
        }

        .scan-cta-btn {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.75rem 1.8rem;
            background: rgba(255, 255, 255, 0.13);
            border: 1px solid rgba(255, 255, 255, 0.35);
            border-radius: 9999px;
            color: white;
            font-weight: 700;
            font-size: 0.9rem;
            backdrop-filter: blur(10px);
            transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
            box-shadow: 0 0 20px rgba(255,255,255,0.05);
        }

        .scan-cta-btn:hover {
            background: rgba(255, 255, 255, 0.22);
            transform: scale(1.03);
            box-shadow: 0 0 28px rgba(255,255,255,0.12);
        }

        /* ─── HUD overlay ─── */
        .scan-hud {
            position: absolute;
            inset: 0;
            z-index: 10;
            pointer-events: none;
        }

        .scan-hud > * {
            pointer-events: auto;
        }

        /* ─── Mode color variables (set via JS) ─── */
        :root {
            --scan-accent: #10b981;
            --scan-accent-glow: rgba(16, 185, 129, 0.35);
        }

        .scan-hud[data-mode="quick"]  { --scan-accent: #10b981; --scan-accent-glow: rgba(16, 185, 129, 0.3); }
        .scan-hud[data-mode="detailed"]{ --scan-accent: #6366f1; --scan-accent-glow: rgba(99, 102, 241, 0.3); }
        .scan-hud[data-mode="batch"]  { --scan-accent: #10b981; --scan-accent-glow: rgba(16, 185, 129, 0.3); }
        .scan-hud[data-mode="smart"]  { --scan-accent: #ec4899; --scan-accent-glow: rgba(236, 72, 153, 0.3); }
        .scan-hud[data-mode="compare"]{ --scan-accent: #06b6d4; --scan-accent-glow: rgba(6, 182, 212, 0.3); }

        /* ─── Top bar ─── */
        .hud-top {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.75rem;
            padding: 1rem 1.25rem;
            background: linear-gradient(
                to bottom,
                rgba(0,0,0,0.55) 0%,
                transparent 100%
            );
        }

        /* ─── Camera status message ─── */
        .hud-status-msg {
            font-size: 0.8rem;
            font-weight: 600;
            color: rgba(255, 255, 255, 0.9);
            text-shadow: 0 1px 3px rgba(0,0,0,0.5);
            max-width: 65%;
            line-height: 1.2;
        }

        /* ─── Scan frame (L-shaped corner brackets) ─── */
        .scan-frame {
            position: absolute;
            inset: 8% 10% 24% 10%;
            pointer-events: none;
        }

        .scan-corner {
            position: absolute;
            width: 1.8rem;
            height: 1.8rem;
            border-color: var(--scan-accent);
            border-style: solid;
            border-width: 0;
            transition: border-color 0.3s;
        }

        .scan-corner.top-left    { top: 0; left: 0;  border-top-width: 2.5px; border-left-width: 2.5px; border-top-left-radius: 4px; }
        .scan-corner.top-right   { top: 0; right: 0; border-top-width: 2.5px; border-right-width: 2.5px; border-top-right-radius: 4px; }
        .scan-corner.bottom-left { bottom: 0; left: 0;  border-bottom-width: 2.5px; border-left-width: 2.5px; border-bottom-left-radius: 4px; }
        .scan-corner.bottom-right{ bottom: 0; right: 0; border-bottom-width: 2.5px; border-right-width: 2.5px; border-bottom-right-radius: 4px; }

        /* Corner glow effect */
        .scan-corner::after {
            content: '';
            position: absolute;
            inset: -4px;
            border-radius: inherit;
            background: var(--scan-accent);
            opacity: 0.08;
            filter: blur(6px);
            transition: background 0.3s, opacity 0.3s;
        }

        .scan-corner.top-left    { animation: cornerPulse 2.4s ease-in-out infinite 0s; }
        .scan-corner.top-right   { animation: cornerPulse 2.4s ease-in-out infinite 0.3s; }
        .scan-corner.bottom-left { animation: cornerPulse 2.4s ease-in-out infinite 0.6s; }
        .scan-corner.bottom-right{ animation: cornerPulse 2.4s ease-in-out infinite 0.9s; }

        @keyframes cornerPulse {
            0%, 100% { opacity: 0.6; }
            50%       { opacity: 1; }
        }

        /* ─── Scan line animation ─── */
        .scan-line-track {
            position: absolute;
            inset: 8% 10% 24% 10%;
            pointer-events: none;
            overflow: hidden;
            border-radius: 4px;
        }

        .scan-line-anim {
            position: absolute;
            left: 0;
            right: 0;
            height: 2px;
            background: linear-gradient(
                90deg,
                transparent 0%,
                var(--scan-accent) 30%,
                var(--scan-accent) 70%,
                transparent 100%
            );
            box-shadow: 0 0 8px var(--scan-accent), 0 0 20px var(--scan-accent-glow);
            top: 0;
            animation: scanDown 2.4s ease-in-out infinite;
            transition: background 0.3s, box-shadow 0.3s;
        }

        @keyframes scanDown {
            0%   { top: 0%;   opacity: 0; }
            5%   { opacity: 1; }
            95%  { opacity: 1; }
            100% { top: 100%; opacity: 0; }
        }

        /* ─── Bottom controls ─── */
        .hud-bottom {
            position: absolute;
            bottom: 2.2rem;
            left: 0;
            right: 0;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 1.5rem;
        }

        .hud-bottom-side {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            min-width: 2.75rem;
        }

        .hud-icon-btn {
            width: 2.75rem;
            height: 2.75rem;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            border: 1.5px solid rgba(255,255,255,0.45);
            background: rgba(0,0,0,0.35);
            color: white;
            backdrop-filter: blur(8px);
            transition: background 0.2s, transform 0.15s, border-color 0.2s;
        }

        .hud-icon-btn:hover {
            background: rgba(255, 255, 255, 0.22);
            border-color: rgba(255, 255, 255, 0.55);
            transform: scale(1.06);
        }

        .hud-icon-btn.active {
            background: rgba(255,255,255,0.18);
            border-color: var(--scan-accent);
            color: var(--scan-accent);
            box-shadow: 0 0 12px var(--scan-accent-glow);
        }

        /* Capture button */
        .hud-capture-wrap {
            position: relative;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .hud-capture-ring {
            position: absolute;
            inset: -9px;
            border-radius: 50%;
            border: 2px solid var(--scan-accent);
            opacity: 0.5;
            box-shadow: 0 0 16px var(--scan-accent-glow);
            animation: ringPulse 2.4s ease-in-out infinite;
            transition: border-color 0.3s, box-shadow 0.3s;
            pointer-events: none;
        }

        @keyframes ringPulse {
            0%, 100% { transform: scale(1);    opacity: 0.5; }
            50%       { transform: scale(1.08); opacity: 0.9; }
        }

        .hud-capture-btn {
            width: 4.5rem;
            height: 4.5rem;
            border-radius: 50%;
            background: white;
            border: 4px solid rgba(255, 255, 255, 0.35);
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: transform 0.1s, border-color 0.2s, box-shadow 0.2s;
            box-shadow: 0 4px 20px rgba(0,0,0,0.3);
            padding: 5px;
        }

        .hud-capture-btn:active {
            transform: scale(0.9);
            border-color: var(--scan-accent);
            box-shadow: 0 0 20px var(--scan-accent-glow);
        }

        .hud-capture-inner {
            width: 100%;
            height: 100%;
            border-radius: 50%;
            background: white;
        }

        /* ─── Zoom panel (slide-up) ─── */
        .zoom-panel {
            position: absolute;
            bottom: 5.5rem;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(0, 0, 0, 0.65);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 9999px;
            backdrop-filter: blur(12px);
            padding: 0.5rem 1rem;
            transition: opacity 0.25s, transform 0.25s;
            z-index: 12;
        }

        .zoom-panel-inner {
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .zoom-slider {
            width: 7rem;
            height: 3px;
            appearance: none;
            -webkit-appearance: none;
            background: rgba(255, 255, 255, 0.3);
            border-radius: 9999px;
            outline: none;
            cursor: pointer;
        }

        .zoom-slider::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 0.9rem;
            height: 0.9rem;
            border-radius: 50%;
            background: white;
            box-shadow: 0 0 4px rgba(0,0,0,0.3);
            cursor: pointer;
        }

        .zoom-label {
            color: rgba(255, 255, 255, 0.9);
            font-size: 0.65rem;
            font-weight: 700;
            min-width: 2rem;
            text-align: center;
        }

        /* Drop overlay */
        .scan-drop-overlay {
            position: absolute;
            inset: 0;
            z-index: 20;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            background: rgba(0, 0, 0, 0.6);
            border: 2.5px dashed rgba(255, 255, 255, 0.7);
        }

        /* Demo panel */
        .scan-demo-panel {
            position: absolute;
            top: 1rem;
            left: 1rem;
            right: 4rem;
            z-index: 10;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.75rem;
            background: rgba(0, 0, 0, 0.55);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 0.75rem;
            padding: 0.6rem 0.75rem;
            backdrop-filter: blur(8px);
        }

        .scan-demo-select {
            background: rgba(255, 255, 255, 0.15);
            border: 1px solid rgba(255, 255, 255, 0.3);
            border-radius: 0.5rem;
            color: white;
            font-size: 0.78rem;
            font-weight: 700;
            padding: 0.25rem 0.5rem;
            outline: none;
            flex: 1;
            min-width: 0;
        }

        .scan-demo-select option {
            background: #1f2937;
            color: white;
        }

        /* Camera status message */
        .tiktok-status {
            pointer-events: none;
        }

        /* Tablet & Desktop adjustments */
        @media (min-width: 768px) {
            .app-container {
                height: 100vh;
                max-width: 1200px;
                margin: 0 auto;
                flex-direction: column;
                padding: 2rem;
                gap: 2rem;
            }

            header {
                width: 100%;
                border-bottom: none !important;
                padding-bottom: 0 !important;
            }

            /* Desktop: Logo and XP bar horizontal */
            @media (min-width: 768px) {
                header > .flex:first-child {
                    flex-direction: row;
                    align-items: center;
                    gap: 2rem;
                }
            }

            main {
                display: flex;
                flex-direction: column;
                flex: 1;
                min-height: 0;
                gap: 2rem;
                padding-bottom: 0 !important;
            }

            .camera-viewport {
                width: 100%;
                border-radius: 1rem;
                aspect-ratio: 4 / 3;
                min-height: 500px;
            }

            section:last-child {
                width: 100%;
            }
        }

        /* Bottom Navigation Bar */
        .nav-bar-container {
            background-color: var(--surface);
            border-top: 1px solid var(--border);
            backdrop-filter: blur(12px);
        }

        .nav-item {
            color: var(--text-secondary);
            transition: color 0.2s;
        }

        .nav-item:hover {
            color: var(--text-primary);
        }

        .nav-item.active {
            color: var(--primary);
        }

        /* Scan page: viewport fills available height */
        #page-scan {
            display: flex;
            flex-direction: column;
            flex: 1;
            min-height: 0;
        }

        /* Main content area — flex column so children expand vertically */
        main {
            display: flex;
            flex-direction: column;
            flex: 1;
            min-height: 0;
            overflow: hidden;
        }

        /* Prevent any page from being independently scrollable */
        .page-content {
            flex: 1;
            min-height: 0;
            overflow: hidden;
            display: flex;
            flex-direction: column;
        }

        /* Other pages scroll normally */
        #page-history,
        #page-quiz,
        #page-profile {
            overflow-y: auto;
            flex: 1;
        }

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

        @keyframes popIn {
            0% { opacity: 0; transform: translateX(-50%) scale(0.8); }
            100% { opacity: 1; transform: translateX(-50%) scale(1); }
        }

        .animate-fade-in {
            animation: fadeIn 0.3s ease-out forwards;
        }

        .animate-pop-in {
            animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
        }

        @keyframes popUp {
            0% { opacity: 0; transform: translateY(20px) scale(0.95); }
            100% { opacity: 1; transform: translateY(0) scale(1); }
        }

        .animate-pop-up {
            animation: popUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
        }

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

        .animate-pulse-glow {
            animation: pulseGlow 2.5s ease-in-out infinite;
        }

        .more-details-icon,
        .accordion-icon {
            transition: transform 0.3s ease-in-out;
        }

        .rotate-180 {
            transform: rotate(180deg);
        }



        /* Fallback UI adjustments */
        .camera-fallback-content {
            padding: 2rem;
        }

        video, canvas {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        /* Flash effect */
        .flash-overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: white;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.1s;
            z-index: 10;
        }

        .flash-overlay.active {
            opacity: 1;
        }

        /* Loading overlay */
        .loading-overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.7);
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            color: white;
            z-index: 20;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s ease;
        }

        .loading-overlay.active {
            opacity: 1;
            pointer-events: auto;
        }

        .scan-line {
            position: absolute;
            left: 12%;
            right: 12%;
            height: 2px;
            top: 30%;
            background: linear-gradient(90deg, transparent, #34d399, transparent);
            box-shadow: 0 0 24px rgba(52, 211, 153, 0.9);
            opacity: 0;
        }

        .loading-overlay.active .scan-line {
            animation: scan-sweep 1.6s ease-in-out infinite;
            opacity: 1;
        }

        @keyframes scan-sweep {
            0% { transform: translateY(0); }
            50% { transform: translateY(170px); }
            100% { transform: translateY(0); }
        }

        .scan-mode-card {
            border: 1px solid var(--border);
            border-radius: 1rem;
            padding: 0.85rem;
            text-align: left;
            background: var(--surface);
            color: var(--text-secondary);
            transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
        }

        .scan-mode-card:hover {
            transform: translateY(-1px);
            border-color: #a7f3d0;
            box-shadow: 0 8px 20px rgba(16, 185, 129, 0.08);
        }

        .scan-mode-card.active {
            border-color: #10b981;
            background: linear-gradient(135deg, rgba(16, 185, 129, 0.13), var(--surface));
            box-shadow: 0 10px 24px rgba(16, 185, 129, 0.13);
        }

        html[data-theme="dark"] #resultsModal,
        html[data-theme="dark"] #quizModal {
            background-color: var(--modal-bg) !important;
            color: var(--text-primary);
        }

        html[data-theme="dark"] .result-card,
        html[data-theme="dark"] .impact-stat-card,
        html[data-theme="dark"] .achievement-card,
        html[data-theme="dark"] .category-breakdown-row,
        html[data-theme="dark"] .quiz-option {
            background-color: var(--surface-muted) !important;
            border-color: var(--border) !important;
            color: var(--text-primary) !important;
        }

        html[data-theme="dark"] .quiz-option:hover,
        html[data-theme="dark"] .result-card:hover {
            background-color: rgba(16, 185, 129, 0.12) !important;
            border-color: rgba(16, 185, 129, 0.45) !important;
        }

        html[data-theme="dark"] .bg-emerald-50 {
            background-color: rgba(6, 78, 59, 0.32) !important;
        }

        html[data-theme="dark"] .bg-blue-50 {
            background-color: rgba(30, 58, 138, 0.32) !important;
        }

        html[data-theme="dark"] .bg-orange-50 {
            background-color: rgba(124, 45, 18, 0.34) !important;
        }

        html[data-theme="dark"] .bg-amber-50 {
            background-color: rgba(120, 53, 15, 0.34) !important;
        }

        html[data-theme="dark"] .bg-gray-900 {
            background-color: #020617 !important;
        }

        .scan-mode-card span,
        .scan-mode-card small {
            display: block;
        }

        .scan-mode-card small {
            color: #6b7280;
            margin-top: 0.15rem;
        }

        /* Snapped photo display */
        #snappedPhoto {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 5;
            object-fit: contain;
            background-color: #000;
        }

        /* Pulsing button animation */
        .pulse-ring {
            position: absolute;
            width: 100%;
            height: 100%;
            border-radius: 50%;
            background-color: rgba(16, 185, 129, 0.4);
            animation: pulse-animation 2s infinite;
            z-index: 0;
        }

        @keyframes pulse-animation {
            0% { transform: scale(1); opacity: 1; }
            100% { transform: scale(1.5); opacity: 0; }
        }

        .grid-overlay {
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            z-index: 4;
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            grid-template-rows: repeat(4, 1fr);
            pointer-events: none;
        }

        .detected-objects-list {
            display: flex;
            gap: 0.75rem;
            overflow-x: auto;
            padding-bottom: 0.25rem;
            scroll-snap-type: x proximity;
            -webkit-overflow-scrolling: touch;
        }

        .detected-objects-list .result-card {
            flex: 0 0 min(280px, 86vw);
            scroll-snap-align: start;
        }

        @media (min-width: 768px) {
            .detected-objects-list {
                display: grid;
                grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
                overflow-x: visible;
            }

            .detected-objects-list .result-card {
                flex: initial;
            }
        }

        .result-card.active {
            border-color: #10b981;
            background: #ecfdf5;
            box-shadow: 0 10px 24px rgba(16, 185, 129, 0.14);
        }

        .grid-cell {
            border: 1px solid rgba(255, 255, 255, 0.42);
            color: rgba(255, 255, 255, 0.75);
            font-size: 0.7rem;
            padding: 0.25rem;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
        }

        .grid-cell.detected {
            background: rgba(16, 185, 129, 0.22);
            outline: 2px solid rgba(52, 211, 153, 0.95);
            outline-offset: -2px;
        }

        .object-focus-box {
            position: absolute;
            z-index: 6;
            border: 3px solid #34d399;
            border-radius: 0.85rem;
            background: rgba(16, 185, 129, 0.16);
            box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.18), 0 0 24px rgba(52, 211, 153, 0.65);
            pointer-events: none;
            transition: all 0.25s ease;
        }

        .result-card {
            animation: result-rise 0.32s ease both;
        }

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

        .achievement-banner {
            border-radius: 1rem;
            padding: 1rem;
            background: linear-gradient(135deg, #fffbeb, #ecfdf5);
            border: 1px solid #fde68a;
            color: #92400e;
            font-weight: 700;
            box-shadow: 0 12px 30px rgba(245, 158, 11, 0.16);
            animation: result-rise 0.28s ease both;
        }

        .achievement-card.locked {
            opacity: 0.55;
            filter: grayscale(0.6);
        }

        html[data-theme="dark"] .achievement-icon {
            background-color: rgba(245, 158, 11, 0.16) !important;
            color: #fbbf24 !important;
        }

        html[data-theme="dark"] .achievement-card.locked .achievement-icon {
            background-color: rgba(148, 163, 184, 0.14) !important;
            color: #94a3b8 !important;
        }

        .impact-stat-card {
            transition: transform 0.18s ease, box-shadow 0.18s ease;
        }

        .impact-stat-card:hover {
            transform: translateY(-1px);
            box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
        }

        .category-breakdown-row {
            padding: 0.75rem;
            border: 1px solid #f3f4f6;
            border-radius: 0.85rem;
            background: #ffffff;
        }

        /* Recent items animation */
        .scan-item {
            transition: transform 0.2s ease, background-color 0.2s ease;
        }
        .scan-item:hover {
            transform: translateY(-2px);
            background-color: #f9fafb;
        }

        /* =============================================
           SETTINGS PANEL REDESIGN
           ============================================= */

        /* Modal inner */
        .settings-modal-inner {
            border: 1px solid var(--border);
            overflow: hidden;
        }

        /* Header */
        .settings-header {
            background: var(--surface);
        }

        .settings-header-icon {
            width: 2.5rem;
            height: 2.5rem;
            border-radius: 0.75rem;
            background: rgba(16, 185, 129, 0.1);
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .settings-close-btn {
            width: 2.25rem;
            height: 2.25rem;
            border-radius: 0.6rem;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-muted);
            transition: background 0.15s, color 0.15s;
        }

        .settings-close-btn:hover {
            background: var(--surface-soft);
            color: var(--text-primary);
        }

        /* Tab Bar */
        .settings-tab-bar {
            display: flex;
            gap: 0.25rem;
            padding: 0 1.25rem;
            background: var(--surface);
            border-bottom: 1px solid var(--border);
            flex-shrink: 0;
        }

        .settings-tab {
            display: flex;
            align-items: center;
            gap: 0.4rem;
            padding: 0.6rem 0.85rem;
            border: none;
            border-bottom: 2px solid transparent;
            background: transparent;
            font-size: 0.8rem;
            font-weight: 600;
            color: var(--text-muted);
            cursor: pointer;
            transition: color 0.15s, border-color 0.15s;
            white-space: nowrap;
        }

        .settings-tab:hover {
            color: var(--text-secondary);
        }

        .settings-tab.active {
            color: var(--primary);
            border-bottom-color: var(--primary);
        }

        /* Tab Body */
        .settings-tab-body {
            padding: 0;
            min-height: 0;
        }

        .settings-tab-pane {
            padding: 1.25rem;
        }

        /* Language row — allow wrapping on narrow screens */
        .settings-row.lang-row {
            flex-wrap: wrap;
        }

        .settings-select-inline {
            width: auto;
            min-width: 6rem;
            flex-shrink: 0;
        }

        /* AI tab — rows and field wrappers with consistent spacing */
        .ai-tab-row {
            margin-top: 0.5rem;
        }

        .ai-tab-field-wrap {
            padding: 0.5rem 1.25rem 0.5rem;
        }

        .ai-tab-field-wrap:first-of-type {
            padding-top: 0;
        }

        /* Provider cards — spacing from provider row */
        #providerCardGroup {
            margin-bottom: 0;
        }

        /* Settings Row */
        .settings-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 1rem;
            padding: 0.85rem 0;
            border-bottom: 1px solid var(--border);
        }

        .settings-row:last-child {
            border-bottom: none;
        }

        /* Settings Row stacked */
        .settings-row.stacked {
            flex-direction: column;
            align-items: flex-start;
        }

        .settings-row-meta {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            flex: 1;
            min-width: 0;
        }

        .settings-row-icon {
            width: 2rem;
            height: 2rem;
            border-radius: 0.6rem;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            background: var(--surface-soft);
        }

        .settings-row-icon.demo {
            background: rgba(34, 211, 238, 0.1);
        }

        .settings-row-label {
            font-size: 0.875rem;
            font-weight: 600;
            color: var(--text-primary);
            line-height: 1.3;
        }

        .settings-row-desc {
            font-size: 0.72rem;
            color: var(--text-muted);
            line-height: 1.4;
            margin-top: 0.1rem;
        }

        /* Theme toggle buttons */
        .theme-toggle-group {
            display: flex;
            gap: 0.4rem;
            flex-shrink: 0;
        }

        .theme-toggle-btn {
            display: flex;
            align-items: center;
            gap: 0.35rem;
            padding: 0.4rem 0.75rem;
            border: 1.5px solid var(--border);
            border-radius: 999px;
            background: var(--surface-muted);
            color: var(--text-muted);
            font-size: 0.78rem;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.15s;
        }

        .theme-toggle-btn:hover {
            border-color: var(--primary);
            color: var(--primary);
        }

        .theme-toggle-btn.active {
            border-color: var(--primary);
            background: rgba(16, 185, 129, 0.1);
            color: var(--primary);
        }

        /* Small select */
        .settings-select-sm {
            width: 100%;
            padding: 0.5rem 0.75rem;
            border: 1px solid var(--border);
            border-radius: 0.6rem;
            font-size: 0.82rem;
            background: var(--input-bg);
            color: var(--text-primary);
            outline: none;
            transition: border-color 0.15s, box-shadow 0.15s;
            appearance: none;
            -webkit-appearance: none;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 0.65rem center;
            padding-right: 2rem;
        }

        .settings-select-sm:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
        }

        /* Input group */
        .settings-input-sm {
            width: 100%;
            padding: 0.5rem 0.75rem;
            border: 1px solid var(--border);
            border-radius: 0.6rem;
            font-size: 0.82rem;
            background: var(--input-bg);
            color: var(--text-primary);
            outline: none;
            transition: border-color 0.15s, box-shadow 0.15s;
        }

        .settings-input-sm:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
        }

        .settings-input-sm::placeholder {
            color: var(--text-muted);
        }

        .settings-input-group {
            position: relative;
            display: flex;
        }

        .settings-input-group .settings-input-sm {
            padding-right: 2.5rem;
        }

        .settings-input-action {
            position: absolute;
            right: 0.65rem;
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-muted);
            cursor: pointer;
            transition: color 0.15s;
        }

        .settings-input-action:hover {
            color: var(--text-secondary);
        }

        /* Toggle Switch */
        .toggle-switch {
            cursor: pointer;
            flex-shrink: 0;
        }

        .toggle-track {
            position: relative;
            width: 2.75rem;
            height: 1.5rem;
            background: var(--border);
            border-radius: 999px;
            transition: background 0.2s;
        }

        .toggle-switch:has(input:checked) .toggle-track {
            background: var(--primary);
        }

        .toggle-thumb {
            position: absolute;
            top: 0.2rem;
            left: 0.2rem;
            width: 1.1rem;
            height: 1.1rem;
            background: white;
            border-radius: 50%;
            transition: transform 0.2s;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
        }

        .toggle-switch:has(input:checked) .toggle-thumb {
            transform: translateX(1.25rem);
        }

        /* Info Banner */
        .settings-info-banner {
            display: flex;
            align-items: flex-start;
            gap: 0.6rem;
            padding: 0.85rem 1rem;
            border-radius: 0.85rem;
            background: rgba(16, 185, 129, 0.08);
            border: 1px solid rgba(16, 185, 129, 0.2);
            font-size: 0.8rem;
            color: var(--text-secondary);
            line-height: 1.5;
            margin-bottom: 0.75rem;
        }

        /* Provider Cards */
        .provider-card-group {
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
            margin-bottom: 1rem;
            padding: 0 0.25rem;
        }

        .provider-card {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0.75rem 1rem;
            border: 1.5px solid var(--border);
            border-radius: 0.85rem;
            background: var(--surface-muted);
            cursor: pointer;
            transition: border-color 0.15s, background 0.15s, transform 0.15s;
            text-align: left;
        }

        .provider-card:hover {
            border-color: var(--primary);
            transform: translateY(-1px);
        }

        .provider-card.active {
            border-color: var(--primary);
            background: rgba(16, 185, 129, 0.06);
        }

        .provider-card-inner {
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }

        .provider-logo-sm {
            width: 2rem;
            height: 2rem;
            border-radius: 0.5rem;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }

        .openai-logo { background: #10a37f; color: white; }
        .openrouter-logo { background: #4f46e5; color: white; }
        .gemini-logo { background: white; color: #3186FF; }

        .provider-card-name {
            font-size: 0.875rem;
            font-weight: 700;
            color: var(--text-primary);
            line-height: 1.2;
        }

        .provider-card-desc {
            font-size: 0.72rem;
            color: var(--text-muted);
            margin-top: 0.1rem;
        }

        .provider-card-check {
            color: var(--primary);
            font-size: 1.2rem;
            opacity: 0;
            transform: scale(0.6);
            transition: opacity 0.15s, transform 0.15s;
        }

        .provider-card.active .provider-card-check {
            opacity: 1;
            transform: scale(1);
        }

        /* API Status */
        #apiKeyStatus {
            padding: 0.6rem 0.85rem;
            border-radius: 0.75rem;
            font-size: 0.8rem;
            display: flex;
            align-items: center;
            gap: 0.5rem;
            font-weight: 600;
        }

        #apiKeyStatus.verified {
            background: rgba(16, 185, 129, 0.1);
            color: #059669;
            border: 1px solid rgba(16, 185, 129, 0.25);
        }

        #apiKeyStatus.error,
        #apiKeyStatus.warning {
            background: rgba(245, 158, 11, 0.1);
            color: #d97706;
            border: 1px solid rgba(245, 158, 11, 0.25);
        }

        /* About Tab */
        .about-hero-card {
            display: flex;
            align-items: center;
            gap: 0.85rem;
            padding: 1rem;
            border-radius: 1rem;
            background: var(--surface-muted);
            border: 1px solid var(--border);
            margin-bottom: 0.75rem;
        }

        .about-app-icon {
            width: 3rem;
            height: 3rem;
            border-radius: 0.85rem;
            background: rgba(16, 185, 129, 0.12);
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }

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

        .about-app-name {
            font-size: 1rem;
            font-weight: 800;
            color: var(--text-primary);
            line-height: 1.2;
        }

        .about-app-tagline {
            font-size: 0.75rem;
            color: var(--text-muted);
            margin-top: 0.15rem;
        }

        .about-version-chip {
            padding: 0.25rem 0.65rem;
            border-radius: 999px;
            font-size: 0.72rem;
            font-weight: 700;
            background: rgba(16, 185, 129, 0.1);
            color: var(--primary);
            border: 1px solid rgba(16, 185, 129, 0.2);
            white-space: nowrap;
        }

        .about-stats-row {
            display: flex;
            align-items: center;
            gap: 0;
            padding: 1rem;
            border-radius: 0.85rem;
            background: var(--surface-muted);
            border: 1px solid var(--border);
            margin-bottom: 0.75rem;
        }

        .about-stat-item {
            flex: 1;
            text-align: center;
        }

        .about-stat-num {
            display: block;
            font-size: 1.75rem;
            font-weight: 800;
            color: var(--text-primary);
            line-height: 1.2;
        }

        .about-stat-label {
            display: block;
            font-size: 0.7rem;
            color: var(--text-muted);
            margin-top: 0.2rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.03em;
        }

        .about-stat-divider {
            width: 1px;
            height: 2.5rem;
            background: var(--border);
            flex-shrink: 0;
        }

        .about-action-list {
            margin-bottom: 1.5rem;
        }

        .about-action-row {
            width: 100%;
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.85rem 1rem;
            border: 1px solid var(--border);
            border-radius: 0.85rem;
            background: var(--surface-muted);
            cursor: pointer;
            transition: border-color 0.15s, background 0.15s;
            text-align: left;
        }

        .about-action-row:hover {
            border-color: #fca5a5;
            background: rgba(239, 68, 68, 0.04);
        }

        .about-action-text {
            flex: 1;
            min-width: 0;
        }

        .about-action-label {
            display: block;
            font-size: 0.875rem;
            font-weight: 700;
            color: #ef4444;
        }

        .about-action-desc {
            display: block;
            font-size: 0.72rem;
            color: var(--text-muted);
            margin-top: 0.1rem;
        }

        .about-footer {
            text-align: center;
            font-size: 0.72rem;
            color: var(--text-muted);
            padding: 0.5rem 0 0.25rem;
            line-height: 1.6;
        }

        /* Footer Buttons */
        .settings-footer {
            display: flex;
            justify-content: flex-end;
            gap: 0.6rem;
            padding: 1rem 1.25rem;
            background: var(--surface-muted);
            border-top: 1px solid var(--border);
            flex-shrink: 0;
        }

        .settings-btn-cancel {
            padding: 0.55rem 1.25rem;
            border-radius: 0.75rem;
            font-size: 0.875rem;
            font-weight: 600;
            color: var(--text-secondary);
            background: var(--surface);
            border: 1px solid var(--border);
            cursor: pointer;
            transition: background 0.15s;
        }

        .settings-btn-cancel:hover {
            background: var(--surface-soft);
        }

        .settings-btn-save {
            display: flex;
            align-items: center;
            gap: 0.4rem;
            padding: 0.55rem 1.25rem;
            border-radius: 0.75rem;
            font-size: 0.875rem;
            font-weight: 700;
            color: white;
            background: var(--primary);
            border: none;
            cursor: pointer;
            transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
            box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
        }

        .settings-btn-save:hover {
            background: var(--primary-dark);
            transform: translateY(-1px);
            box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
        }

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

        /* Dark mode for settings */
        html[data-theme="dark"] .settings-info-banner {
            background: rgba(16, 185, 129, 0.08);
            border-color: rgba(16, 185, 129, 0.2);
        }

        html[data-theme="dark"] .provider-card {
            background: var(--surface-muted);
        }

        html[data-theme="dark"] .about-hero-card,
        html[data-theme="dark"] .about-stats-row,
        html[data-theme="dark"] .about-action-row {
            background: var(--surface-muted);
        }

        html[data-theme="dark"] .settings-row-icon {
            background: rgba(16, 185, 129, 0.1);
        }

        /* Scrollbar */
        .settings-tab-body::-webkit-scrollbar {
            width: 3px;
        }

        .settings-tab-body::-webkit-scrollbar-track {
            background: transparent;
        }

        .settings-tab-body::-webkit-scrollbar-thumb {
            background: var(--border);
            border-radius: 2px;
        }

        /* Utility: hide ugly horizontal scrollbar */
        .hide-scrollbar {
            scrollbar-width: none;       /* Firefox */
            -ms-overflow-style: none;    /* IE/Edge */
        }

        .hide-scrollbar::-webkit-scrollbar {
            display: none;               /* Chrome/Safari/Opera */
        }

        /* RecycleDex Styles */
        .recycledex-silhouette {
            filter: grayscale(100%) brightness(0.2) contrast(0.8);
            opacity: 0.5;
        }
        .recycledex-card {
            transition: transform 0.2s, box-shadow 0.2s;
        }
        .recycledex-card:hover {
            transform: translateY(-2px);
        }
        .recycledex-card.unlocked {
            box-shadow: 0 4px 12px rgba(0,0,0,0.05);
        }
