/* ═══════════════════════════════════════════════════════════════════════
   Re-Life — Stylesheet
   Fully readable, organized by component.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Reset ──────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Config: Design Tokens ─────────────────────────────────────────── */
:root {
    /* Glass */
    --glass-bg-light: rgba(255, 255, 255, 0.45);
    --glass-bg-dark: rgba(31, 35, 30, 0.5);
    --glass-border-light: rgba(255, 255, 255, 0.4);
    --glass-border-dark: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.08), 0 4px 12px 0 rgba(0, 0, 0, 0.04);
    /* Palette */
    --color-primary:        #3d6a4b;
    --color-primary-hover:  #2f5239;
    --color-primary-light:  #d4e8d8;
    --color-primary-mid:    #5a9a6b;
    --color-bg:             #f0f4ef;
    --color-bg-alt:         #e8ede6;
    --color-white:          #ffffff;
    --color-gray-50:        #f9faf8;
    --color-gray-100:       #f3f5f2;
    --color-gray-200:       #e3e6e1;
    --color-gray-400:       #9ca39a;
    --color-gray-500:       #6b7268;
    --color-gray-700:       #3d423b;
    --color-gray-800:       #1f231e;
    --color-amber-200:      #fef3c7;
    --color-amber-400:      #f59e0b;
    --color-emerald-50:     #ecfdf5;
    --color-emerald-100:    #d1fae5;
    --color-emerald-200:    #a7f3d0;
    --color-emerald-700:    #047857;
    --color-emerald-800:    #065f46;
    --color-red-400:        #f87171;
    --color-red-500:        #ef4444;
    /* Radii */
    --radius-sm:  10px;
    --radius-md:  14px;
    --radius-lg:  20px;
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.08);

    --glass-bg-light: rgba(255, 255, 255, 0.45);
    --glass-bg-dark: rgba(31, 35, 30, 0.5);
    --glass-border-light: rgba(255, 255, 255, 0.4);
    --glass-border-dark: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.08), 
                    0 4px 12px 0 rgba(0, 0, 0, 0.04);

    /* Advanced animation easing (Apple-spring style) */
    --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
    --spring-wobbly: cubic-bezier(0.34, 1.56, 0.64, 1);
    --spring-smooth: cubic-bezier(0.43, 0.13, 0.23, 0.96);

    /* Unified transition durations */
    --transition-fast: 0.15s var(--ease-out-quint);
    --transition-normal: 0.3s var(--ease-out-quint);
    --transition-spring: 0.5s var(--spring-wobbly);

    /* ── Typography ───────────────────────────────────────────────── */
    --font-display: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

    /* Type scale */
    --text-xs:   0.6875rem;
    --text-sm:   0.8125rem;
    --text-base: 0.9375rem;
    --text-md:   1.0625rem;
    --text-lg:   1.25rem;
    --text-xl:   1.5rem;
    --text-2xl:  1.875rem;

    /* Line heights */
    --leading-tight:  1.2;
    --leading-normal: 1.5;
    --leading-relaxed: 1.7;

    /* Font weights */
    --weight-normal: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;
    --weight-black: 900;
}

/* Smooth theme switching */
body, .app, .card, .btn, .upload-zone, .record-card, .result-card,
.app-header, nav.nav, .app-nav, .login-card, .login-page {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

/* ── Base ──────────────────────────────────────────────────────────── */
html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-gray-800);
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    -webkit-font-smoothing: antialiased;
    line-height: var(--leading-normal);
    font-size: var(--text-base);
}

/* ── App Shell ─────────────────────────────────────────────────────── */
.app {
    width: 100%;
    max-width: 430px;
    height: 100dvh;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    background:
        radial-gradient(ellipse at 20% 10%, rgba(45,90,61,0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 90%, rgba(166,140,80,0.05) 0%, transparent 50%),
        var(--color-bg);
}
/* Organic grain overlay */
.app::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── Premium cards ─────────────────────────────────────────────────── */
.login-card, .card, .tips-card, .fact-card, .rewards-wallet, .result-card {
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 20px;
    border: 1px solid rgba(0,0,0,0.05);
    box-shadow: 0 1px 3px rgba(0,0,0,0.03), 0 4px 16px rgba(0,0,0,0.04);
}
.card { padding: 20px; }
.card-header {
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--color-gray-400);
    margin-bottom: 16px;
}

/* Hardware acceleration for smooth animations on low-end devices */
.app {
    will-change: opacity;
    backface-visibility: hidden;
}
/* Other elements keep transform for GPU acceleration */
.card, .scan-btn, .tab, .modal, .nav-btn-icon {
    will-change: transform, opacity;
    backface-visibility: hidden;
    transform: translate3d(0, 0, 0);
}

/* ── Header ────────────────────────────────────────────────────────── */
.app-header {
    position: absolute;
    top: 15px;
    left: 15px;
    width: calc(100% - 30px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: rgba(255,255,255,0.10);
    backdrop-filter: blur(20px) brightness(1.15) saturate(150%);
    -webkit-backdrop-filter: blur(20px) brightness(1.15) saturate(150%);
    border: 1px solid rgba(255,255,255,0.3);
    box-shadow: 0 4px 24px rgba(0,0,0,0.10), inset 0 1px 3px rgba(255,255,255,0.3);
    border-radius: 20px;
    z-index: 100;
    transition: box-shadow 0.2s ease;
}
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .app-header { background: rgba(255,255,255,0.88); }
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-title {
    font-size: 1.125rem;
    font-weight: var(--weight-black);
    color: var(--color-primary);
    letter-spacing: -0.02em;
}

.header-time, .header-user {
    font-size: 11px;
    font-weight: 500;
    color: var(--color-gray-700);
    opacity: 0.9;
}

.header-user {
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    background: var(--color-primary);
    color: white;
    cursor: pointer;
    transition: transform 0.15s;
}

.header-avatar:active {
    transform: scale(0.9);
}

/* ── Main Content ───────────────────────────────────────────────────── */
.main {
    flex: 1;
    padding: 95px 16px 120px;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    box-sizing: border-box;
}

/* ── Tabs ──────────────────────────────────────────────────────────── */
.tab {
    display: none;
    flex-direction: column;
    gap: 12px;
    opacity: 0;
}

/* Active tab with spring entrance animation */
.tab.active {
    display: flex;
    animation: slideInTab 0.4s var(--ease-out-quint) forwards;
}

@keyframes slideInTab {
    from {
        opacity: 0;
        transform: scale(0.97) translateY(12px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ── Card ──────────────────────────────────────────────────────────── */
.card {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    padding: 18px;
    border: 1px solid var(--color-gray-200);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, transform 0.2s;
    color: var(--color-gray-800);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-gray-400);
    text-align: center;
    margin-bottom: 14px;
}

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border: none;
    border-radius: 14px;
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    letter-spacing: 0.01em;
    min-height: 44px;
}

.btn:active {
    transform: scale(0.96);
}

.btn--primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
    color: var(--color-white);
    box-shadow: 0 2px 8px rgba(61, 106, 75, 0.25);
}

.btn--primary:hover {
    background: var(--color-primary-hover);
    box-shadow: 0 4px 14px rgba(61, 106, 75, 0.35);
    transform: translateY(-1px);
}

.btn--primary:disabled {
    background: var(--color-gray-200);
    color: var(--color-gray-400);
    cursor: not-allowed;
}

.btn--outline {
    background: transparent;
    border: 1.5px solid var(--color-gray-200);
    color: var(--color-gray-700);
}

.btn--outline:hover {
    border-color: var(--color-gray-400);
}

.btn--danger {
    background: var(--color-red-500);
    border: 1.5px solid var(--color-red-500);
    color: #fff;
    padding: 5px 10px;
    font-size: 10px;
    border-radius: var(--radius-sm);
}

.btn--danger:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

.btn--small {
    padding: 6px 12px;
    font-size: 10px;
}

.btn--full {
    width: 100%;
}

/* ── Scan Action Buttons ───────────────────────────────────────────── */
.scan-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    perspective: 1000px;
}

.scan-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 10px;
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    cursor: pointer;
    text-align: center;
    gap: 8px;
    font-family: inherit;
    
    /* Refined spring transitions */
    transition: transform 0.4s var(--spring-wobbly),
                box-shadow 0.3s var(--ease-out-quint),
                background-color 0.3s ease,
                border-color 0.3s ease;
}

.scan-btn--dispose {
    animation-delay: 0.15s;
}

.scan-btn--purchase {
    animation-delay: 0.25s;
}

/* Hover: subtle 3D lift */
.scan-btn:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 20px rgba(61, 106, 75, 0.12);
}

/* Active: satisfying press feedback */
.scan-btn:active {
    transform: translateY(1px) scale(0.96);
    transition: transform 0.1s var(--ease-out-quint);
}

.scan-btn--dispose,
.scan-btn--purchase {
    background: var(--color-gray-100);
    border: 2px solid var(--color-gray-200);
}

.scan-btn--dispose:hover,
.scan-btn--purchase:hover {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.scan-btn--active {
    transform: scale(1.04);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-primary) !important;
    animation: pulseBorder 2s infinite ease-in-out;
}

@keyframes pulseBorder {
    0%, 100% { border-color: var(--color-primary); }
    50% { border-color: var(--color-primary-mid); }
}

.scan-btn--active.scan-btn--dispose,
.scan-btn--active.scan-btn--purchase {
    background: var(--color-primary-light);
    border-color: var(--color-primary) !important;
}

.scan-btn-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    overflow: hidden;
    background: transparent;
}

.scan-btn-label {
    font-size: 11px;
    font-weight: 800;
    color: var(--color-gray-700);
    letter-spacing: 0.04em;
}

.scan-btn-sub {
    font-size: 8px;
    color: var(--color-gray-500);
}

/* ── AI Toggle ──────────────────────────────────────────────────────── */
.ai-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
}

.ai-row-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--color-gray-500);
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-row-status {
    font-size: 9px;
    font-weight: 700;
    color: var(--color-emerald-700);
}

.ai-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--color-gray-200);
    border-radius: 99px;
    cursor: pointer;
    transition: background 0.2s;
    border: none;
}

.ai-switch.is-active {
    background: var(--color-emerald-800);
}

.ai-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: var(--color-white);
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.ai-switch.is-active::after {
    transform: translateX(20px);
}

.select-field {
    width: 100%;
    padding: 7px 9px;
    font-size: 10px;
    font-weight: 600;
    background: var(--color-gray-50);
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-sm);
    color: var(--color-gray-700);
    cursor: pointer;
    font-family: inherit;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2378716c' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 26px;
}

.select-field:focus {
    outline: none;
    border-color: var(--color-primary-mid);
    box-shadow: 0 0 0 2px rgba(74, 93, 78, 0.1);
}

/* ── Upload Zone ───────────────────────────────────────────────────── */
.upload-zone {
    text-align: center;
    cursor: pointer;
    background: var(--color-white);
    color: var(--color-gray-800);
    border: 2px dashed var(--color-gray-200);
    border-radius: 20px;
    padding: 36px 16px 28px;
    position: relative;
    transition: all 0.3s ease;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.upload-zone:hover {
    background: rgba(4, 120, 87, 0.05);
    border-color: var(--color-primary-hover);
    cursor: pointer;
}

.upload-zone.drag-over {
    transform: scale(1.02);
    background: rgba(4, 120, 87, 0.1);
    border-color: var(--color-emerald-700);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.upload-zone.drag-over .upload-zone-icon {
    animation: pulse 0.5s ease-in-out infinite;
}

.upload-zone-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: transparent;
}

.upload-zone-text {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-gray-800);
    margin-bottom: 2px;
}

.upload-zone-sub {
    font-size: 10px;
    color: var(--color-gray-400);
    margin-top: 2px;
}

.upload-gallery-link {
    display: inline-block;
    margin-top: 10px;
    font-size: 10px;
    font-weight: 600;
    color: var(--color-primary-mid);
    cursor: pointer;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.upload-gallery-link:hover {
    background: var(--color-primary-light);
}

/* Image preview pop-in animation */
@keyframes scalePop {
    from { opacity: 0; transform: scale(0.8) rotate(-2deg); }
    to { opacity: 1; transform: scale(1) rotate(0deg); }
}

.upload-preview {
    overflow: hidden;
    border-radius: var(--radius-md);
    animation: scalePop 0.4s var(--spring-wobbly) forwards;
    position: relative;
    display: none;
}

.upload-preview.is-shown {
    display: block;
}

/* When upload zone has image, make it fill the zone */
.upload-zone.has-image {
    padding: 0;
    overflow: hidden;
}
.upload-zone.has-image .upload-preview {
    border-radius: 22px;
}
.upload-zone.has-image .upload-preview img {
    max-height: 220px;
    border-radius: 22px;
    width: 100%;
    object-fit: cover;
}

.upload-preview img {
    width: 100%;
    max-height: 160px;
    object-fit: cover;
    border-radius: var(--radius-md);
}

.upload-preview-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.55);
    color: var(--color-white);
    border: none;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Record Card ───────────────────────────────────────────────────── */
.record-card, .rewards-coupon {
    animation: cardEntrance 0.5s var(--ease-out-quint) both;
}

.record-card:nth-child(1) { animation-delay: 0.05s; }
.record-card:nth-child(2) { animation-delay: 0.10s; }
.record-card:nth-child(3) { animation-delay: 0.15s; }

@keyframes cardEntrance {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.record-card {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-gray-200);
    overflow: hidden;
    transition: box-shadow 0.2s;
    margin-bottom: 10px;
}

.record-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.record-card-inner {
    display: flex;
    gap: 12px;
    padding: 12px;
}

.record-card-image {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    background: var(--color-gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    flex-shrink: 0;
    overflow: hidden;
}

.record-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.record-card-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-gray-800);
}

.record-card-meta {
    display: flex;
    gap: 5px;
    align-items: center;
    margin-top: 3px;
    flex-wrap: wrap;
}

.record-card-badge {
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 99px;
    letter-spacing: 0.04em;
}

.record-card-badge--purchase {
    background: var(--color-emerald-100);
    color: var(--color-emerald-800);
}

.record-card-badge--dispose {
    background: var(--color-gray-100);
    color: var(--color-gray-500);
}

.record-card-ratings {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

.record-card-actions {
    display: flex;
    justify-content: flex-end;
    padding: 0 12px 8px;
}

/* ── Rating / Stars ────────────────────────────────────────────────── */
.rating-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.rating-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--color-gray-400);
    text-transform: uppercase;
}

.star-rating {
    display: flex;
    gap: 1px;
}

.star {
    font-size: 12px;
    color: var(--color-gray-200);
}

.star.is-filled {
    color: var(--color-amber-400);
}

.rating-value {
    font-size: 9px;
    font-weight: 700;
    color: #92400e;
    margin-left: 2px;
}

/* ── Alternative Product ───────────────────────────────────────────── */
.alternative-card {
    background: var(--color-emerald-50);
    border: 1px solid var(--color-emerald-200);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-top: 10px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}
.alternative-card-label {
    color: var(--color-emerald-700);
}

.alternative-card:hover {
    box-shadow: var(--shadow-md);
}

.alternative-card-label {
    font-size: 10px;
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    color: var(--color-emerald-700);
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.alternative-card-name {
    font-size: 13px;
    font-weight: var(--weight-bold);
    color: var(--color-gray-800);
}

.alternative-card-ratings {
    display: flex;
    gap: 14px;
    margin-top: 4px;
}

/* ── Weighted Score Breakdown ──────────────────────────────────────── */
.weighted-section {
    margin-top: 12px;
}

.weighted-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.weighted-title {
    font-size: 10px;
    font-weight: 800;
    color: var(--color-gray-700);
}

.weighted-toggle {
    font-size: 9px;
    font-weight: 700;
    color: var(--color-emerald-700);
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.overall-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-top: 1px solid var(--color-gray-100);
    margin-bottom: 6px;
}

.overall-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-gray-500);
}

.overall-value {
    font-size: 18px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.overall-max {
    font-size: 10px;
    color: var(--color-gray-400);
}

.grade-row {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 10px;
    font-weight: 700;
}

.grade-tag {
    padding: 2px 9px;
    border-radius: 99px;
    color: var(--color-white);
    font-size: 9px;
}

.overall-bar {
    width: 100%;
    height: 10px;
    background: var(--color-gray-100);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 10px;
}

.overall-bar-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.8s cubic-bezier(0.25, 0.8, 0.25, 1.2);
    position: relative;
    overflow: hidden;
    animation: barSlideIn 0.9s cubic-bezier(0.25, 0.8, 0.25, 1.2);
}

.overall-bar-fill::after {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
    0%   { left: -100%; }
    100% { left: 200%; }
}

.weighted-detail {
    display: none;
    flex-direction: column;
    gap: 6px;
}

.weighted-detail.is-open {
    display: flex;
}

.criterion-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.criterion-header {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    font-weight: 600;
}

.criterion-name {
    color: var(--color-gray-700);
}

.criterion-score {
    color: var(--color-gray-500);
    font-variant-numeric: tabular-nums;
}

.criterion-bar {
    width: 100%;
    height: 24px;
    background: var(--color-gray-100);
    border-radius: 99px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.criterion-bar:active {
    cursor: grabbing;
}

.criterion-bar-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.4s ease;
    position: relative;
    overflow: hidden;
    pointer-events: none;
    min-width: 0;
}

.criterion-bar-fill::after {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
    animation: shimmer 2.5s ease-in-out infinite;
}

/* Slide-in from zero */
.criterion-bar-fill.is-animated {
    animation: barSlideIn 0.7s cubic-bezier(0.25, 0.8, 0.25, 1.2);
}

@keyframes barSlideIn {
    from { width: 0 !important; }
}

/* ── Disposal Guide ────────────────────────────────────────────────── */
.disposal-guide {
    background: var(--color-gray-50);
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    margin-top: 10px;
}

.disposal-guide-title {
    font-size: 10px;
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    color: var(--color-primary);
    letter-spacing: 0.05em;
    margin-bottom: 5px;
}

.disposal-guide-row {
    display: flex;
    gap: 5px;
    font-size: 9px;
    color: var(--color-gray-700);
    margin-bottom: 2px;
}

.disposal-guide-label {
    font-weight: 700;
    color: var(--color-gray-500);
    white-space: nowrap;
}

.disposal-guide-precaution {
    font-size: 10px;
    color: var(--color-red-500);
    font-weight: var(--weight-semibold);
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px solid var(--color-gray-200);
}

/* ── Scan Result ───────────────────────────────────────────────────── */
.result-card {
    background: var(--color-white);
    border-radius: 20px;
    border: 1px solid var(--color-gray-200);
    padding: 24px 18px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.05);
}

/* Staggered children for scan result card */
.result-card .record-card-image,
.result-card .result-card-name,
.result-card .result-card-tip,
.result-card .rating-item,
.result-card .overall-score-section,
.result-card .criterion-row,
.result-card .disposal-guide,
.result-card .result-card-actions {
    animation: crossfadeIn 0.35s ease both;
}
.result-card .record-card-image       { animation-delay: 0.05s; }
.result-card .result-card-name        { animation-delay: 0.1s; }
.result-card .result-card-tip         { animation-delay: 0.15s; }
.result-card .rating-item             { animation-delay: 0.2s; }
.result-card .criterion-row:nth-child(1) { animation-delay: 0.25s; }
.result-card .criterion-row:nth-child(2) { animation-delay: 0.3s; }
.result-card .criterion-row:nth-child(3) { animation-delay: 0.35s; }
.result-card .criterion-row:nth-child(4) { animation-delay: 0.4s; }
.result-card .criterion-row:nth-child(5) { animation-delay: 0.45s; }
.result-card .disposal-guide          { animation-delay: 0.5s; }
.result-card .result-card-actions     { animation-delay: 0.55s; }

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

.result-card .record-card-image {
    width: 72px;
    height: 72px;
    margin: 0 auto 10px;
    font-size: 32px;
}

.result-card-name {
    font-size: 15px;
    font-weight: 700;
    text-align: center;
    color: var(--color-gray-800);
}

.result-card-tip {
    font-size: 10px;
    color: var(--color-gray-500);
    text-align: center;
    margin-top: 4px;
}

.gemini-error {
    font-size: 10px;
    color: var(--color-red-500);
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    margin-top: 6px;
    text-align: left;
    word-break: break-word;
    font-family: monospace;
}

[data-theme="dark"] .gemini-error {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.3);
}

.result-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 12px;
}

.result-card-actions .btn {
    flex: 1;
}

/* ── News Card ──────────────────────────────────────────────────────── */
.tips-card {
    background: 
        radial-gradient(circle at 90% 10%, rgba(255,255,255,0.06) 0%, transparent 50%),
        radial-gradient(circle at 10% 90%, rgba(0,0,0,0.1) 0%, transparent 40%),
        linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
    color: #fff;
    border-radius: 14px;
    padding: 14px 16px;
    position: relative;
    overflow: hidden;
}
.tips-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 2px,
        rgba(255,255,255,0.02) 2px,
        rgba(255,255,255,0.02) 4px
    );
    pointer-events: none;
}

.tips-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.tips-pill {
    font-size: 9px;
    font-weight: 700;
    background: var(--color-amber-400);
    color: var(--color-gray-800);
    padding: 2px 8px;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tips-source {
    font-size: 9px;
    color: rgba(255,255,255,0.5);
}

.tips-title {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
    margin-bottom: 4px;
    transition: opacity 0.2s ease;
}
.tips-title a { color: #fff; }
.tips-title.is-switching { opacity: 0; }

.tips-snippet {
    font-size: 11px;
    color: rgba(255,255,255,0.6);
    line-height: 1.4;
    margin-bottom: 10px;
    transition: opacity 0.2s ease;
}
.tips-snippet.is-switching { opacity: 0; }

.tips-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tips-dots { display: flex; gap: 5px; }

.tips-dot {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    transition: all 0.2s;
    cursor: pointer;
}

.tips-dot.is-active {
    background: var(--color-amber-400);
    width: 14px;
    border-radius: 99px;
}

.tips-more {
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    background: rgba(255,255,255,0.1);
    border: none;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}

.tips-more:hover { background: rgba(255,255,255,0.2); }

/* ── Fact Card ──────────────────────────────────────────────────────── */
.fact-card {
    background: var(--color-gray-50);
    border: 1px solid var(--color-gray-200);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.fact-card-icon {
    font-size: 18px;
}

.fact-card-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--color-gray-700);
}

.fact-card-text {
    font-size: 10px;
    color: var(--color-gray-500);
    line-height: 1.4;
    margin-top: 2px;
}

/* ── Rewards ────────────────────────────────────────────────────────── */
.rewards-wallet {
    background: var(--color-primary);
    color: var(--color-white);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
}

.rewards-wallet::before {
    content: '🎁';
    position: absolute;
    right: -6px;
    top: -6px;
    font-size: 70px;
    opacity: 0.07;
}

.rewards-label {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--color-emerald-200);
    letter-spacing: 0.05em;
    position: relative;
    z-index: 1;
}

.rewards-points {
    font-size: 28px;
    font-weight: 900;
    color: var(--color-amber-200);
    position: relative;
    z-index: 1;
    margin: 4px 0;
}

.rewards-sub {
    font-size: 10px;
    color: #dee2e6;
    position: relative;
    z-index: 1;
}

.rewards-shortcut {
    display: none;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 1;
    justify-content: space-between;
    align-items: center;
}

.rewards-shortcut.is-shown {
    display: flex;
}

.rewards-alert {
    display: none;
    background: #fee2e2;
    border: 1px solid var(--color-red-400);
    color: var(--color-red-500);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 10px;
    font-weight: 600;
    align-items: center;
    gap: 6px;
}

.rewards-alert.is-shown {
    display: flex;
}

.rewards-item {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-gray-200);
    padding: 14px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    transition: box-shadow 0.2s;
    animation: slideUpStagger 0.35s ease both;
}

.rewards-item:nth-child(1) { animation-delay: 0.04s; }
.rewards-item:nth-child(2) { animation-delay: 0.1s; }
.rewards-item:nth-child(3) { animation-delay: 0.16s; }
.rewards-item:nth-child(4) { animation-delay: 0.22s; }
.rewards-item:nth-child(n+5) { animation-delay: 0.28s; }

.rewards-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.rewards-item-image {
    width: 44px;
    height: 44px;
    background: #f4f7f0;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

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

.rewards-item-provider {
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--color-emerald-800);
    background: var(--color-emerald-50);
    padding: 2px 7px;
    border-radius: 99px;
    display: inline-block;
}

.rewards-item-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--color-gray-800);
    margin-top: 4px;
}

.rewards-item-desc {
    font-size: 9px;
    color: var(--color-gray-500);
    margin-top: 2px;
    line-height: 1.4;
}

.rewards-item-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    min-width: 60px;
}

.rewards-item-cost {
    font-size: 12px;
    font-weight: 900;
    color: var(--color-emerald-800);
}

.rewards-item-btn {
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-size: 9px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.rewards-item-btn--can-buy {
    background: var(--color-primary);
    color: var(--color-white);
}

.rewards-item-btn--cannot-buy {
    background: var(--color-gray-100);
    color: var(--color-gray-400);
    cursor: not-allowed;
}

.rewards-coupons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: transparent;
}

.rewards-coupon {
    background: var(--color-gray-50);
    color: var(--color-gray-700);
    padding: 10px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(0, 0, 0, 0.04);
    cursor: pointer;
    transition: border 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    min-width: 0;
    font-family: inherit;
}
.rewards-coupon > * {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rewards-coupon:hover {
    border-color: var(--color-emerald-700);
}

/* ── More Tab ──────────────────────────────────────────────────────── */
.more-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.api-key-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 11px;
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-md);
    background: var(--color-gray-50);
    font-family: monospace;
    outline: none;
}

.api-key-input:focus {
    border-color: var(--color-primary-mid);
}

.eco-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 11px;
    color: var(--color-gray-700);
    cursor: pointer;
    padding: 4px 0;
}

.eco-check input {
    accent-color: var(--color-emerald-800);
    margin-top: 2px;
}

/* ── Policy Card ───────────────────────────────────────────────────── */
.policy-card {
    background: var(--color-primary);
    color: var(--color-white);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
}

.policy-card::before {
    content: '🛡️';
    position: absolute;
    right: -8px;
    bottom: -8px;
    font-size: 70px;
    opacity: 0.05;
}

.policy-card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-amber-200);
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 6px;
}

.policy-card-text {
    font-size: 10px;
    color: #dee2e6;
    line-height: 1.5;
    margin-top: 6px;
    position: relative;
    z-index: 1;
}

.policy-card-footer {
    display: flex;
    justify-content: space-between;
    padding-top: 8px;
    margin-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 9px;
    color: var(--color-emerald-200);
    position: relative;
    z-index: 1;
}

/* ── Modals ─────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.is-shown {
    display: flex;
}

.modal {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-lg);
    padding: 28px 20px;
    max-width: 340px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 1px 0 rgba(255, 255, 255, 0.3) inset;
    animation: modalPop 0.3s cubic-bezier(0.25, 0.8, 0.25, 1.2);
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.92) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* -- Entrance Animations (NEW) ---------------------------------------- */
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.88); }
    to   { opacity: 1; transform: scale(1); }
}

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

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.06); }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(61, 106, 75, 0.35); }
    50%      { box-shadow: 0 0 0 14px rgba(61, 106, 75, 0); }
}

@keyframes spinPulse {
    0%   { transform: rotate(0deg); box-shadow: 0 0 8px rgba(61, 106, 75, 0.15); }
    50%  { box-shadow: 0 0 22px rgba(61, 106, 75, 0.4); }
    100% { transform: rotate(360deg); box-shadow: 0 0 8px rgba(61, 106, 75, 0.15); }
}

@keyframes dotBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%           { transform: translateY(-7px); }
}

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

@keyframes countPop {
    from { opacity: 0; transform: scale(0.7); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes bgShift {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}

/* -- Utility animation classes ---------------------------------------- */
.anim-entrance {
    animation: slideUpStagger 0.45s cubic-bezier(0.25, 0.8, 0.25, 1.2) both;
}

.anim-entrance.is-count {
    animation: countPop 0.4s cubic-bezier(0.25, 0.8, 0.25, 1.2) both;
}

.modal-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.modal-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--color-gray-800);
    margin-bottom: 6px;
}

.modal-body {
    font-size: 12px;
    color: var(--color-gray-500);
    line-height: 1.5;
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.modal-actions .btn {
    flex: 1;
}

/* ── Camera Modal ───────────────────────────────────────────────────── */
.camera-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: #000;
    flex-direction: column;
}

.camera-modal.is-shown {
    display: flex;
}

.camera-modal video {
    flex: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

.camera-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px 28px;
    background: rgba(0, 0, 0, 0.35);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
}

.camera-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: transform 0.15s;
    font-family: inherit;
}

.camera-btn:active {
    transform: scale(0.92);
}

.camera-btn--close {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.camera-btn--flip {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.camera-btn--capture {
    width: 72px;
    height: 72px;
    background: none;
    padding: 0;
}

.camera-capture-ring {
    display: block;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 4px solid #fff;
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.2);
}

/* ── Coupon Code ───────────────────────────────────────────────────── */
.coupon-code {
    font-size: 18px;
    font-weight: 900;
    font-family: monospace;
    color: var(--color-emerald-800);
    background: var(--color-emerald-50);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 2px dashed var(--color-emerald-200);
    letter-spacing: 0.05em;
    margin: 8px 0;
}

.coupon-expiry {
    font-size: 10px;
    color: var(--color-gray-400);
}

/* ── Bottom Nav ────────────────────────────────────────────────────── */
nav.nav, .app-nav {
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom, 20px));
    left: 0; right: 0;
    margin: 0 auto;
    width: calc(100% - 30px);
    max-width: 400px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 0;
    background: rgba(255,255,255,0.10);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    border-radius: 28px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.08), 0 0 0 0.5px rgba(255,255,255,0.08);
    padding: 5px 6px;
    z-index: 100;
    overflow: visible;
    transition: transform 0.35s cubic-bezier(.22,1,.36,1);
}
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    nav.nav, .app-nav { background: rgba(255,255,255,0.85); }
}

/* Sliding nav indicator */
.nav-indicator {
    position: absolute;
    top: 5px;
    height: calc(100% - 10px);
    background: rgba(0,0,0,0.06);
    border-radius: 20px;
    pointer-events: none;
    z-index: 1;
    will-change: left, width, top, height, border-radius;
    transition: left 0.4s cubic-bezier(.22,1,.36,1), width 0.4s cubic-bezier(.22,1,.36,1);
}
.nav-is-dragging .nav-indicator {
    top: -4px;
    height: calc(100% + 8px);
    border-radius: 24px;
    background: rgba(0,0,0,0.10);
}
[data-theme="dark"] .nav-indicator,
[data-theme="midnight"] .nav-indicator {
    background: rgba(255,255,255,0.12);
}
[data-theme="dark"] .nav-is-dragging .nav-indicator,
[data-theme="midnight"] .nav-is-dragging .nav-indicator {
    background: rgba(255,255,255,0.18);
}

/* Hide floating bars when camera is active */
body:has(.camera-modal.is-shown) .app-nav,
body:has(.camera-modal.is-shown) nav.nav,
body:has(.camera-modal.is-shown) .app-header,
.camera-active .app-nav,
.camera-active nav.nav,
.camera-active .app-header {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.nav-btn {
    flex: 1;
    display: flex;
    position: relative;
    z-index: 2;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 4px 6px;
    font-size: 8px;
    font-weight: 600;
    color: var(--color-gray-500);
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    position: relative;
}

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

.nav-btn.is-active, .nav-btn:hover {
    color: var(--color-primary);
    font-weight: 700;
}

.nav-btn-icon {
    font-size: 20px;
    line-height: 1;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.nav-btn.is-active .nav-btn-icon {
    transform: scale(1.1);
}

/* ── Footer ────────────────────────────────────────────────────────── */
.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 18px;
    background: var(--color-white);
    border-top: 1px solid var(--color-gray-200);
    font-size: 10px;
    color: var(--color-gray-500);
}

.footer-lang {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 10px;
    font-weight: 600;
    color: var(--color-gray-500);
    padding: 3px 6px;
    border-radius: 6px;
    transition: background 0.2s;
}

.footer-lang:hover {
    background: var(--color-gray-100);
}

/* ── Stats Bar ─────────────────────────────────────────────────────── */
.stats-bar {
    display: flex;
    gap: 8px;
}

.stat {
    flex: 1;
    background: var(--color-white);
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-md);
    padding: 12px 10px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-number.anim-entrance {
    animation: countPop 0.45s cubic-bezier(0.25, 0.8, 0.25, 1.2) both;
}

.stat:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-number {
    font-size: 18px;
    font-weight: 900;
    color: var(--color-primary);
    letter-spacing: -0.5px;
}

.stat-label {
    font-size: 8px;
    color: var(--color-gray-400);
    text-transform: uppercase;
    margin-top: 3px;
    letter-spacing: 0.05em;
}

/* ── Scanning Status ───────────────────────────────────────────────── */
.scanning-status {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    background: var(--color-white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-gray-200);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

[data-theme="dark"] .scanning-status {
    background: var(--color-gray-100);
    border-color: var(--color-gray-200);
}

.scanning-status.is-shown {
    display: flex;
}

/* Spinning ring loader */
.scanning-spinner {
    width: 56px;
    height: 56px;
    border: 4px solid rgba(4, 120, 87, 0.1);
    border-left-color: var(--color-primary-mid);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
    position: relative;
}
.scanning-spinner::after {
    content: '';
    position: absolute;
    top: -8px; left: -8px; right: -8px; bottom: -8px;
    border-radius: 50%;
    border: 2px solid rgba(4, 120, 87, 0.3);
    animation: spinnerPulse 1.5s ease-out infinite;
}

@keyframes spinnerPulse {
    0% { transform: scale(0.9); opacity: 1; }
    100% { transform: scale(1.4); opacity: 0; }
}

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

/* Shimmering gradient text during scanning */
.scanning-text {
    font-weight: 700;
    font-size: 14px;
    background: linear-gradient(90deg, var(--color-gray-800), var(--color-primary), var(--color-gray-800));
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shineText 1.5s linear infinite;
}

@keyframes shineText {
    to { background-position: 200% center; }
}

.scanning-hint {
    font-size: 9px;
    color: var(--color-gray-400);
    margin-top: 4px;
}

/* Bouncing dots loader */
.scanning-spinner-dots {
    display: flex;
    gap: 6px;
    margin-top: 12px;
}
.scanning-spinner-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-primary);
    animation: dotBounce 1.4s ease-in-out infinite both;
}
.scanning-spinner-dots span:nth-child(1) { animation-delay: 0s; }
.scanning-spinner-dots span:nth-child(2) { animation-delay: 0.2s; }
.scanning-spinner-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.3; }
    40% { transform: translateY(-8px); opacity: 1; }
}

/* ── Empty State ───────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 36px 20px;
    color: var(--color-gray-400);
}

.empty-state-icon {
    font-size: 42px;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 12px;
    font-weight: 500;
}

/* ── Utilities ─────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--color-gray-500); }
.text-sm { font-size: 11px; }
.text-xs { font-size: 10px; }
.font-bold { font-weight: 700; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.flex-col { display: flex; flex-direction: column; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.w-full { width: 100%; }
.rounded { border-radius: var(--radius-md); }
.img-cover { width: 100%; height: 100%; object-fit: contain; }

/* ── Shared component classes ─────────────────────────────────────── */
.section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-gray-800);
}
.section-divider {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--color-gray-200);
}
.btn-icon {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    margin-right: 6px;
}
.rew-view-btn {
    background: var(--color-amber-400);
    color: var(--color-primary);
    font-weight: 700;
    font-size: 10px;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-family: inherit;
}

/* ── Scrollbar ─────────────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 3px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.02);
}

::-webkit-scrollbar-thumb {
    background: rgba(74, 93, 78, 0.2);
    border-radius: 99px;
}

/* ── Responsive ────────────────────────────────────────────────────── */
@media (min-width: 431px) {
    .app {
        border-left: 1px solid var(--color-gray-200);
        border-right: 1px solid var(--color-gray-200);
    }
}

/* ── Login Page ──────────────────────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    background: radial-gradient(circle at top left, var(--color-primary-light) 0%, var(--color-bg) 60%);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--color-gray-800);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

.login-shell {
    width: 100%;
    max-width: 380px;
    padding: 24px;
}

.login-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-lg);
    padding: 36px 24px 24px;
    box-shadow: 0 20px 60px rgba(31, 38, 135, 0.10), 0 1px 0 rgba(255, 255, 255, 0.3) inset;
    animation: modalPop 0.4s cubic-bezier(0.25, 0.8, 0.25, 1.2);
}

.login-brand {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo {
    font-size: 48px;
    margin-bottom: 6px;
    line-height: 1;
}

.login-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--color-primary);
    letter-spacing: -0.4px;
}

.login-sub {
    font-size: 11px;
    color: var(--color-gray-500);
    margin-top: 2px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Login entrance animations */
.login-field {
    animation: slideUpStagger 0.4s ease both;
}
.login-field:nth-child(1) { animation-delay: 0.1s; }
.login-field:nth-child(2) { animation-delay: 0.2s; }
.login-btn { animation: slideUpStagger 0.4s 0.3s ease both; }
.login-divider { animation: crossfadeIn 0.3s 0.35s ease both; }

.login-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.login-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-gray-400);
}

.login-input {
    width: 100%;
    padding: 12px 14px;
    font-size: 14px;
    font-family: inherit;
    background: var(--color-gray-50);
    border: 2px solid var(--color-gray-200);
    border-radius: var(--radius-sm);
    color: var(--color-gray-800);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.login-input:focus {
    border-color: var(--color-primary-mid);
    box-shadow: 0 0 0 3px rgba(90, 154, 107, 0.15);
}

.login-input::placeholder {
    color: var(--color-gray-400);
}

.login-error {
    font-size: 10px;
    font-weight: 600;
    color: var(--color-red-500);
    min-height: 16px;
    line-height: 1.3;
}

.login-btn {
    width: 100%;
    padding: 13px 16px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.02em;
}

.login-btn:active {
    transform: scale(0.97);
}

.login-btn--primary {
    background: var(--color-primary);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(61, 106, 75, 0.25);
}

.login-btn--primary:hover {
    background: var(--color-primary-hover);
}

.login-btn--ghost {
    background: transparent;
    color: var(--color-gray-500);
    border: 2px solid var(--color-gray-200);
}

.login-btn--ghost:hover {
    background: var(--color-gray-50);
    color: var(--color-gray-700);
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 10px;
    color: var(--color-gray-400);
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-gray-200);
}

.login-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid var(--color-gray-200);
}

.login-footer-link {
    font-size: 10px;
    font-weight: 600;
    color: var(--color-gray-500);
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
}

.login-footer-link:hover {
    color: var(--color-primary);
}

.login-footer-dot {
    font-size: 10px;
    color: var(--color-gray-400);
}

.login-footer-text {
    font-size: 9px;
    color: var(--color-gray-400);
    font-weight: 500;
}

/* ── Dark Theme ────────────────────────────────────────────────────── */
[data-theme="dark"] {
    --color-primary:        #4a9a5b;
    --color-primary-hover:  #5aae6b;
    --color-primary-light:  #1e3a28;
    --color-primary-mid:    #3a7a4b;
    --color-bg:             #0f120f;
    --color-bg-alt:         #151815;
    --color-white:          #1a1f1a;
    --color-gray-50:        #161a16;
    --color-gray-100:       #1e231e;
    --color-gray-200:       #2a302a;
    --color-gray-400:       #7a807a;
    --color-gray-500:       #9aa09a;
    --color-gray-700:       #c8cec8;
    --color-gray-800:       #e8ebe8;
    --color-amber-200:      #5a4a20;
    --color-amber-400:      #d4a017;
    --color-emerald-50:     #122016;
    --color-emerald-100:    #182a1e;
    --color-emerald-200:    #1e3a28;
    --color-emerald-700:    #4ade80;
    --color-emerald-800:    #6ee7a0;
    --color-red-400:        #ef4444;
    --color-red-500:        #f87171;
}

[data-theme="dark"] body {
    color: var(--color-gray-800);
}

[data-theme="dark"] .app-header,
[data-theme="dark"] nav.nav,
[data-theme="dark"] .app-nav {
    background: rgba(20, 30, 20, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] .header-title {
    color: var(--color-emerald-200);
}

[data-theme="dark"] .header-time,
[data-theme="dark"] .header-user {
    color: var(--color-gray-200);
}

[data-theme="dark"] .card,
[data-theme="dark"] .record-card,
[data-theme="dark"] .result-card {
    border-color: var(--color-gray-200);
}

[data-theme="dark"] .upload-zone {
    background: var(--color-gray-50);
}

[data-theme="dark"] .upload-zone:active {
    background: var(--color-gray-100);
}

[data-theme="dark"] .nav {
    border-color: var(--color-gray-200);
}

[data-theme="dark"] .footer {
    border-color: var(--color-gray-200);
}

[data-theme="dark"] .modal {
    background: rgba(30, 36, 30, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .modal-title {
    color: var(--color-gray-800);
}

[data-theme="dark"] .modal-body {
    color: var(--color-gray-500);
}

[data-theme="dark"] .select-field {
    background: var(--color-gray-100);
    color: var(--color-gray-800);
    border-color: var(--color-gray-200);
}

[data-theme="dark"] input,
[data-theme="dark"] textarea {
    background: var(--color-gray-100);
    color: var(--color-gray-800);
    border-color: var(--color-gray-200);
}

[data-theme="dark"] .api-key-input {
    background: var(--color-gray-100);
    color: var(--color-gray-800);
}

[data-theme="dark"] .btn--primary {
    color: #e5e7e5;
}

[data-theme="dark"] .btn--primary:hover {
    background: var(--color-primary-hover);
}

[data-theme="dark"] .btn--primary:disabled {
    background: var(--color-gray-200);
    color: var(--color-gray-500);
}

[data-theme="dark"] .btn--outline {
    border-color: var(--color-gray-200);
    color: var(--color-gray-800);
}

[data-theme="dark"] .btn--outline:hover {
    background: var(--color-gray-100);
}

[data-theme="dark"] .btn--danger {
    background: var(--color-red-500);
    color: #e5e7e5;
}

[data-theme="dark"] .btn--danger:hover {
    color: #e5e7e5;
}

[data-theme="dark"] .upload-gallery-link {
    color: var(--color-emerald-700);
}

[data-theme="dark"] .upload-gallery-link:hover {
    background: var(--color-emerald-50);
}

[data-theme="dark"] .record-card-badge--dispose {
    background: var(--color-gray-200);
    color: var(--color-gray-400);
}

[data-theme="dark"] .record-card-badge--purchase {
    background: var(--color-emerald-100);
    color: var(--color-emerald-700);
}

[data-theme="dark"] .scanning-status {
    background: var(--color-gray-50);
}

[data-theme="dark"] .disposal-guide {
    background: var(--color-gray-50);
    border-color: var(--color-gray-200);
}

[data-theme="dark"] .nav-btn.is-active {
    color: var(--color-primary-light);
}

[data-theme="dark"] .ai-switch::after {
    background: #e5e7e5;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .result-card-name,
[data-theme="dark"] .record-card-name {
    color: var(--color-gray-800);
}

[data-theme="dark"] .result-card-tip,
[data-theme="dark"] .record-card-meta {
    color: var(--color-gray-500);
}

[data-theme="dark"] .tips-title {
    color: var(--color-gray-800);
}

[data-theme="dark"] .tips-snippet {
    color: var(--color-gray-500);
}

[data-theme="dark"] .fact-card-title {
    color: var(--color-gray-800);
}

[data-theme="dark"] .fact-card-text {
    color: var(--color-gray-500);
}

[data-theme="dark"] .rewards-label,
[data-theme="dark"] .rewards-sub {
    color: var(--color-emerald-200);
}

/* Fix --color-white used as text on dark backgrounds */
[data-theme="dark"] .tips-card {
    color: #e5e7e5;
}

[data-theme="dark"] .rewards-wallet {
    color: #e5e7e5;
}

[data-theme="dark"] .policy-card {
    color: #e5e7e5;
}

[data-theme="dark"] .rewards-item-btn--can-buy {
    color: #e5e7e5;
}

[data-theme="dark"] .grade-tag {
    color: #e5e7e5;
}

/* ── Dark mode: scan mode active buttons ──────────────────────────── */
[data-theme="dark"] .scan-btn--active.scan-btn--dispose {
    background: #1e3a28;
    border-color: var(--color-emerald-700);
}

[data-theme="dark"] .scan-btn--active.scan-btn--purchase {
    background: #1e3a28;
    border-color: var(--color-emerald-700);
}

/* ── Dark mode: danger button ─────────────────────────────────────── */
[data-theme="dark"] .btn--danger {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}
[data-theme="dark"] .btn--danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

/* ── Dark mode: login page ────────────────────────────────────────── */
[data-theme="dark"] .login-page {
    background: radial-gradient(circle at top left, #1a2a1e 0%, #0f120f 60%);
}

[data-theme="dark"] .login-card {
    background: rgba(20, 28, 20, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .login-title {
    color: var(--color-emerald-200);
}

[data-theme="dark"] .login-sub {
    color: var(--color-gray-500);
}

[data-theme="dark"] .login-input {
    background: var(--color-gray-100);
    border-color: var(--color-gray-200);
    color: var(--color-gray-800);
}

[data-theme="dark"] .login-input:focus {
    border-color: var(--color-emerald-700);
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.15);
}

[data-theme="dark"] .login-btn--ghost {
    border-color: var(--color-gray-200);
    color: var(--color-gray-500);
}

[data-theme="dark"] .login-btn--ghost:hover {
    background: var(--color-gray-100);
    color: var(--color-gray-800);
}

[data-theme="dark"] .login-footer {
    border-top-color: var(--color-gray-200);
}

[data-theme="dark"] .login-divider::before,
[data-theme="dark"] .login-divider::after {
    background: var(--color-gray-200);
}

/* ── Dark mode: upload zone ───────────────────────────────────────── */
[data-theme="dark"] .upload-zone.drag-over {
    background-color: rgba(74, 154, 91, 0.15);
    box-shadow: 0 0 0 6px rgba(74, 154, 91, 0.12);
}

/* ── Click Ripple Effect ──────────────────────────────────────────── */
.btn--primary, .scan-btn, .login-btn--primary {
    position: relative;
    overflow: hidden;
}

.click-ripple {
    position: absolute;
    background: rgba(255, 255, 255, 0.35);
    width: 100px;
    height: 100px;
    margin-left: -50px;
    margin-top: -50px;
    border-radius: 50%;
    animation: rippleEffect 0.6s var(--ease-out-quint) both;
    pointer-events: none;
}

@keyframes rippleEffect {
    from {
        transform: scale(0);
        opacity: 1;
    }
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* -- Reduced Motion --------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ── Nav bar drag/swipe ────────────────────────────────────────────── */
nav.nav, .app-nav {
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
    cursor: grab;
}
nav.nav:active { cursor: grabbing; }

.nav-btn.is-active {
    transform: scale(1.08);
}
.nav-btn.is-active .nav-btn-icon {
    filter: drop-shadow(0 4px 10px rgba(61, 106, 75, 0.25));
    animation: elasticPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes elasticPop {
    0% { transform: scale(0.85); }
    70% { transform: scale(1.12); }
    100% { transform: scale(1); }
}
.nav-btn img {
    pointer-events: none;
    -webkit-user-drag: none;
}

/* ── Step animations (register flow) ───────────────────────────────── */
.step {
    animation: fadeScale 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes fadeScale {
    from { opacity: 0; transform: scale(0.98) translateY(6px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
