:root {
    --bg: #fffcf9;
    --card: rgba(255, 255, 255, 0.85);
    --border: rgba(212, 175, 55, 0.2);
    --text: #2c1810;
    --text-dim: #5c4033;
    
    --accent: #8b0000;
    --accent-glow: rgba(139, 0, 0, 0.2);
    --accent-alt: #d4af37;
    
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --font-h: 'Cormorant Garamond', serif;
    --font-b: 'Plus Jakarta Sans', sans-serif;
}

[data-theme="dark"] {
    --bg: #1a0f0f;
    --card: rgba(44, 24, 24, 0.8);
    --border: rgba(212, 175, 55, 0.15);
    --text: #fdf5e6;
    --text-dim: #d2b48c;
    --accent: #ff4d4d;
    --accent-glow: rgba(255, 77, 77, 0.3);
}

* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent; 
}

html, body {
    width: 100%;
    height: 100%;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-b);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background 0.5s var(--ease);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.glow-mesh {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(at 0% 0%, var(--accent-glow) 0, transparent 45%),
                radial-gradient(at 100% 100%, rgba(212, 175, 55, 0.1) 0, transparent 45%);
    z-index: -1;
    pointer-events: none;
}

.heart-particles {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1;
    pointer-events: none;
}

/* ===== NAVIGATION ===== */
.glass-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 2rem;
    background: var(--card);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0; z-index: 1000;
    gap: 1rem;
}

.logo { 
    font-family: var(--font-h); 
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 1px;
    white-space: nowrap;
}

.logo span { 
    color: var(--accent-alt);
    background: linear-gradient(135deg, var(--accent), var(--accent-alt));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.theme-btn {
    background: rgba(212, 175, 55, 0.1);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.6rem;
    border-radius: 50%;
    cursor: pointer;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
}

.theme-btn:hover {
    background: rgba(212, 175, 55, 0.2);
}

[data-theme="dark"] .sun-icon, 
[data-theme="light"] .moon-icon { 
    display: none; 
}

/* ===== MAIN WRAPPER ===== */
.main-wrapper { 
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 2rem;
    width: 100%;
}

/* ===== HERO SECTION ===== */
.hero-section { 
    text-align: center;
    margin-bottom: 2.5rem;
    padding: 0;
}

.hero-section h1 { 
    font-family: var(--font-h);
    font-size: 4rem;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 1rem;
    letter-spacing: -0.01em;
}

.gradient-text { 
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-alt) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: inline-block;
}

.subtitle { 
    color: var(--text-dim);
    font-size: 1.4rem;
    font-weight: 400;
    max-width: 750px;
    margin: 0 auto;
    line-height: 1.6;
    font-family: var(--font-h);
    font-style: italic;
}

/* ===== APP CARD ===== */
.app-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 3rem;
    padding: 3rem;
    box-shadow: 0 30px 60px -12px rgba(44, 24, 24, 0.15);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

/* ===== UPLOAD GRID ===== */
.upload-grid { 
    display: grid;
    grid-template-columns: 1fr 120px 1fr;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.upload-box {
    aspect-ratio: 1/1;
    background: rgba(212, 175, 55, 0.02);
    border: 1px solid var(--border);
    border-radius: 2.5rem;
    cursor: pointer;
    transition: 0.5s var(--ease);
    position: relative;
    overflow: hidden;
    width: 100%;
}

.upload-box:hover { 
    border-color: var(--accent-alt);
    background: rgba(212, 175, 55, 0.05);
    transform: translateY(-5px) scale(1.01);
    box-shadow: 0 20px 40px rgba(212, 175, 55, 0.1);
}

.upload-box.drag-active {
    border-color: var(--accent);
    background: rgba(139, 0, 0, 0.08);
    transform: scale(1.03);
}

.box-content { 
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1rem;
}

.upload-icon { 
    color: var(--accent-alt);
    margin-bottom: 0.5rem;
    transition: 0.3s;
}

.upload-box:hover .upload-icon {
    transform: scale(1.1);
    color: var(--accent);
}

.upload-icon svg {
    width: 44px;
    height: 44px;
}

.empty-ui h3 { 
    font-family: var(--font-h);
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-dim);
}

.preview-wrap { 
    position: absolute;
    top: 0; left: 0;
    width: 100%; 
    height: 100%;
    border-radius: 2.5rem;
    overflow: hidden;
}

.preview-img { 
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    image-rendering: -webkit-optimize-contrast;
    animation: fadeIn 0.6s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(1.05); }
    to { opacity: 1; transform: scale(1); }
}

.scan-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: radial-gradient(circle, transparent 30%, var(--accent-glow) 100%);
    animation: pulseGlow 3s infinite ease-in-out;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 0.3; transform: scale(0.95); }
    50% { opacity: 0.6; transform: scale(1.05); }
}

/* ===== NEXUS GRAPHIC ===== */
.nexus-graphic { 
    position: relative;
    width: 100px;
    height: 100px;
}

.nexus-graphic svg { 
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 25px var(--accent-glow));
    animation: pulseHeart 1.5s infinite ease-in-out;
}

@keyframes pulseHeart {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 15px var(--accent-glow)); }
    50% { transform: scale(1.15); filter: drop-shadow(0 0 35px var(--accent)); }
}

.pulse-rings span {
    position: absolute;
    top: 50%; left: 50%;
    border: 2px solid var(--accent-alt);
    border-radius: 50%;
    opacity: 0;
    animation: elegantPulse 3s infinite;
}

.pulse-rings span:nth-child(2) {
    animation-delay: 1.5s;
}

@keyframes elegantPulse {
    0% { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
    20% { opacity: 0.6; }
    100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}

/* ===== ACTION FOOTER ===== */
.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-alt) 100%);
    color: white;
    border: none;
    padding: 1.4rem 2rem;
    border-radius: 50px;
    font-size: 1.3rem;
    font-family: var(--font-h);
    font-weight: 600;
    cursor: pointer;
    transition: 0.4s var(--ease);
    box-shadow: 0 10px 30px var(--accent-glow);
    letter-spacing: 1px;
}

.btn-primary:hover:not(:disabled) { 
    transform: translateY(-3px);
    box-shadow: 0 15px 40px var(--accent-glow);
    filter: brightness(1.1);
}

.btn-primary:disabled { 
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.5;
}

/* ===== LOADING ===== */
#loading-overlay {
    margin-top: 3rem;
    text-align: center;
    padding: 2rem;
    background: rgba(212, 175, 55, 0.05);
    border-radius: 2rem;
    border: 1px solid var(--border);
    animation: slideUp 0.6s var(--ease);
}

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

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s infinite cubic-bezier(0.5, 0, 0.5, 1);
    margin: 0 auto 1.5rem;
}

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

#loader-msg {
    font-family: var(--font-h);
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1rem;
}

.progress-bar-wrap {
    height: 6px;
    background: var(--border);
    border-radius: 10px;
    margin-top: 1.5rem;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-alt));
    width: 0%;
    transition: width 0.4s ease;
    box-shadow: 0 0 10px var(--accent-glow);
}


/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(44, 24, 24, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: flex-start; /* Better for tall content */
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: 0.4s var(--ease);
    padding: 2rem 1rem;
    overflow-y: auto; /* Enable scrolling */
}

.modal-overlay:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 2.5rem;
    padding: 3rem 1.5rem 2.5rem;
    max-width: 450px;
    width: 100%;
    text-align: center;
    position: relative;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.4);
    transform: translateY(40px);
    transition: 0.5s var(--ease);
    margin: auto; /* Centers correctly within the scrollable container */
}

.modal-overlay:not(.hidden) .modal-card {
    transform: translateY(0);
}

.close-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(212, 175, 55, 0.1);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
    z-index: 10;
}

.close-btn:hover {
    background: var(--accent);
    color: white;
}

.badge {
    display: inline-block;
    padding: 0.4rem 1rem;
    background: rgba(212, 175, 55, 0.1);
    color: var(--accent-alt);
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.modal-title {
    font-family: var(--font-h);
    font-size: 2.2rem;
    color: var(--text);
    margin-bottom: 2rem;
    line-height: 1.2;
}

.score-radial {
    width: 160px; height: 160px;
    margin: 0 auto 2rem;
    position: relative;
}

.score-radial svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.radial-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 6;
}

.radial-fill {
    fill: none;
    stroke: var(--accent);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    transition: stroke-dashoffset 2s var(--ease);
}

.score-content {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-h);
    font-weight: 700;
    display: flex;
    align-items: baseline;
    justify-content: center;
    color: var(--text);
}

#score-num {
    font-size: 3.5rem;
    line-height: 1;
}

.score-content small {
    font-size: 1.4rem;
    margin-left: 2px;
}

.verdict-container {
    padding: 0 1rem;
}

.verdict-container h3 {
    font-family: var(--font-h);
    font-size: 1.8rem;
    margin-bottom: 0.8rem;
    color: var(--accent);
}

.verdict-container p {
    font-family: var(--font-b);
    color: var(--text-dim);
    line-height: 1.6;
    font-size: 1rem;
}

.modal-footer {
    margin-top: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.share-group {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.share-label {
    font-size: 0.9rem;
    color: var(--text-dim);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.social-btns {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.social-btn {
    width: 50px;
    height: 50px;
    border-radius: 15px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s var(--ease);
}

.social-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.social-btn.facebook:hover {
    background: #1877f2;
    color: white;
    border-color: #1877f2;
}

.social-btn.reddit {
    background: #ff450015; /* Subtle orange tint */
}

.social-btn.reddit:hover {
    background: #ff4500;
    color: white;
    border-color: #ff4500;
}

.social-btn.copy:hover {
    background: var(--accent-alt);
    color: white;
    border-color: var(--accent-alt);
}

.social-btn img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.legal-footer {
    text-align: center;
    padding: 3rem;
    font-family: var(--font-h);
    opacity: 0.6;
}

.hidden {
    display: none !important;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .main-wrapper { padding: 1.5rem 1rem; }
    .hero-section h1 { font-size: 2.2rem; }
    .subtitle { font-size: 1.1rem; }
    .upload-grid { 
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .connector { 
        height: 80px; 
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100%;
    }
    .nexus-graphic { width: 60px; height: 60px; }
    .upload-box { max-width: 320px; margin: 0 auto; }
    .app-card { padding: 1.5rem; border-radius: 2rem; }
    .btn-primary { padding: 1.2rem; font-size: 1.1rem; }
}

@media (max-width: 480px) {
    .hero-section h1 { font-size: 1.8rem; }
    .subtitle { font-size: 1rem; }
    .upload-box { max-width: 100%; aspect-ratio: 16/10; }
    .modal-card { padding: 2.5rem 1.25rem 1.5rem; border-radius: 2rem; }
    .modal-title { font-size: 1.8rem; margin-bottom: 1rem; }
    .score-radial { width: 130px; height: 130px; margin-bottom: 1.5rem; }
    #score-num { font-size: 2.8rem; }
    .verdict-container h3 { font-size: 1.5rem; }
    .verdict-container p { font-size: 0.95rem; }
    .share-group { padding-top: 1rem; }
    .social-btn { width: 44px; height: 44px; border-radius: 12px; }
    .close-btn { top: 1rem; right: 1rem; width: 32px; height: 32px; font-size: 1.2rem; }
}
