:root {
    /* Swapped Colors for "ViberNet Purple" Theme */
    --vn-blue: #AF52DE;  /* Primary/Download is now Purple */
    --vn-purple: #007AFF; /* Secondary/Upload is now Blue */
    
    --vn-dark: #1D1D1F;
    --vn-gray: #F5F5F7;
    --vn-border: #E5E5EA;
    --vn-success: #34C759;
    --vn-warning: #FF9500;
    --vn-danger: #FF3B30;
    
    --font-stack: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
    --radius-std: 16px;
    --radius-sm: 10px;
}

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

body {
    font-family: var(--font-stack);
    background-color: #FFFFFF;
    color: var(--vn-dark);
    overflow-x: hidden;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
}

.vn-main {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

/* --- Header --- */
.vn-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 24px 40px;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.vn-header-left { display: flex; align-items: center; }
.vn-logo-img { height: 40px; width: auto; display: block; }

.vn-header-right {
    font-size: 14px;
    font-weight: 500;
}

.vn-header-link {
    text-decoration: none;
    color: #666;
    transition: color 0.2s;
}
.vn-header-link:hover { color: var(--vn-blue); }
.vn-header-link .highlight { color: #BBB; font-weight: 400; transition: color 0.2s; }
.vn-header-link:hover .highlight { color: var(--vn-blue); }


/* --- Active Test --- */
.vn-section {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.vn-active-test {
    justify-content: center;
    align-items: center;
    position: relative;
    height: 100vh;
    min-height: 600px; /* Prevent squashing on small landscapes */
}

.vn-center-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 10;
    margin-bottom: 60px; /* Lifted up slightly */
}

/* Status Pill */
.vn-status-pill {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    background: white;
    border: 1px solid var(--vn-border);
    padding: 6px 16px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 500;
    color: #666;
    box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}
.vn-badge {
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}
.bg-blue { background: #F3E6FF; color: var(--vn-blue); }
.bg-purple { background: #E6F2FF; color: var(--vn-purple); }
.hidden { display: none !important; }

/* Hero Number */
.vn-hero { text-align: center; margin-bottom: 50px; }
.vn-value {
    font-size: 130px;
    font-weight: 800;
    line-height: 0.9;
    letter-spacing: -4px;
    font-feature-settings: "tnum";
    color: var(--vn-dark);
}
.vn-unit {
    font-size: 16px;
    font-weight: 500;
    color: #999;
    margin-top: 12px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* Active Test GO Button */
.vn-btn {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 1px solid #E0E0E0;
    background: white;
    color: var(--vn-dark);
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.06);
}
.vn-btn:hover {
    border-color: var(--vn-blue);
    color: var(--vn-blue);
    transform: scale(1.05);
    box-shadow: 0 15px 40px rgba(175, 82, 222, 0.15);
}

/* Graph */
.vn-graph-container-large {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 35vh;
    opacity: 0.5;
    pointer-events: none;
}
canvas { width: 100%; height: 100%; }

/* Active Footer */
.vn-active-footer {
    position: absolute;
    bottom: 30px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    z-index: 10;
}
.vn-af-item { display: flex; flex-direction: column; align-items: flex-start; }
.vn-af-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #AAA;
    margin-bottom: 2px;
    letter-spacing: 0.05em;
}
.vn-af-val { font-size: 13px; font-weight: 600; color: #333; }
.vn-af-divider { width: 1px; height: 20px; background: #EEE; }


/* --- RESULTS PAGE --- */
.vn-results {
    background: #FAFAFA;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    min-height: 100vh;
}

.vn-dashboard-container {
    display: grid;
    grid-template-columns: 2.2fr 1fr;
    gap: 40px;
    max-width: 1200px;
    width: 100%;
    margin-bottom: 40px;
}

/* Left Column */
.vn-col-tech {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.vn-results-header {
    margin-bottom: 8px;
    text-align: left;
}

.vn-res-heading {
    font-size: 20px;
    font-weight: 700;
    color: #111;
    margin-bottom: 8px;
}

/* Verdict Banner */
.vn-verdict-banner {
    display: inline-block;
    font-size: 14px;
    font-weight: 600;
    color: #2E7D32;
    background: #E8F5E9;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid #C8E6C9;
}

/* Cards Layout */
.vn-cards-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.vn-tech-card {
    background: white;
    border: 1px solid var(--vn-border);
    border-radius: var(--radius-std);
    padding: 24px 24px 16px 24px;
    box-shadow: 0 4px 20px -5px rgba(0,0,0,0.05);
    transition: transform 0.2s;
}
.vn-tech-card:hover { transform: translateY(-2px); }

.vn-tech-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.vn-label-sm { 
    font-size: 12px; 
    font-weight: 700; 
    text-transform: uppercase; 
    letter-spacing: 0.05em;
}
.text-blue { color: var(--vn-blue); }
.text-purple { color: var(--vn-purple); }

.vn-res-group {
    display: flex;
    align-items: baseline;
    gap: 4px;
}
.vn-res-big { 
    font-size: 48px;
    font-weight: 700; 
    color: #111;
    line-height: 1; 
    letter-spacing: -1px;
}
.vn-unit-sm { font-size: 14px; font-weight: 500; color: #999; }

.vn-graph-wrapper {
    height: 70px; 
    width: 100%;
    margin-top: 4px;
    opacity: 0.9;
}

/* Net Grid */
.vn-net-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
.vn-net-item {
    background: white;
    border: 1px solid var(--vn-border);
    padding: 16px;
    border-radius: var(--radius-sm);
}
.vn-net-item.full-width { grid-column: span 4; display: flex; align-items: center; justify-content: space-between; }

.vn-label-xs { 
    font-size: 11px; 
    font-weight: 600; 
    color: #999; 
    text-transform: uppercase; 
    margin-bottom: 4px; 
    letter-spacing: 0.05em;
}
.full-width .vn-label-xs { margin-bottom: 0; }

.vn-val-row { display: flex; align-items: center; gap: 8px; }
.vn-val-md { font-size: 14px; font-weight: 600; color: #222; }
.small { font-size: 13px; color: #555; }

/* Context Tags */
.vn-tag { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; }
.tag-good { background: #E8F5E9; color: #2E7D32; }
.tag-ok { background: #FFF3E0; color: #EF6C00; }
.tag-bad { background: #FFEBEE; color: #C62828; }


/* PRIMARY ACTION AREA */
.vn-action-area {
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.vn-btn-primary-action {
    background: var(--vn-blue);
    border: none;
    color: white;
    font-family: var(--font-stack);
    font-weight: 600;
    font-size: 15px;
    padding: 14px 28px; /* Reverted to compact padding */
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(175, 82, 222, 0.25);
    /* Removed flex: 1 to keep it compact as requested */
    min-width: 140px;
}
.vn-btn-primary-action:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(175, 82, 222, 0.35);
}

.vn-btn-secondary {
    background: white;
    border: 1px solid var(--vn-border);
    color: #555;
    font-family: var(--font-stack);
    font-weight: 500;
    font-size: 15px;
    padding: 14px 24px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.vn-btn-secondary:hover {
    border-color: #CCC;
    background: #F9F9F9;
    color: #333;
    transform: translateY(-2px);
}


/* --- RIGHT COLUMN: MARKETING CARD --- */
.vn-col-marketing {
    display: flex;
    flex-direction: column;
}

.vn-promo-box {
    background: #FFFFFF;
    padding: 32px;
    border-radius: var(--radius-std);
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    border: 1px solid var(--vn-border);
    background: linear-gradient(to bottom, #FFFFFF, #FAFAFA);
}

.vn-promo-icon-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #F3E6FF; 
    color: var(--vn-blue);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}

.vn-promo-box h3 { 
    font-size: 20px; 
    font-weight: 700; 
    color: #111;
    margin-bottom: 8px;
}

.vn-promo-text { 
    color: #555; 
    font-size: 14px; 
    margin-bottom: 20px; 
    line-height: 1.5; 
}

.vn-check-list-vertical { 
    list-style: none;
    margin-bottom: 24px;
    text-align: left;
    width: fit-content;
}
.vn-check-list-vertical li { 
    margin-bottom: 8px; 
    font-weight: 500; 
    font-size: 13px; 
    color: #444;
    display: flex;
    align-items: center;
}
.vn-check-list-vertical span { color: var(--vn-blue); font-weight: 700; margin-right: 8px; }

.vn-price-tag { 
    font-size: 13px; 
    color: #666; 
    margin-bottom: 20px; 
}
.vn-price-tag strong { color: #111; font-size: 18px; font-weight: 700; }

.vn-btn-ghost {
    display: inline-block;
    background: transparent;
    border: 1px solid #CCC;
    color: #333;
    text-align: center;
    padding: 10px 24px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s;
}
.vn-btn-ghost:hover { 
    border-color: #333;
    color: black;
}

/* Footer */
.vn-results-footer {
    width: 100%;
    text-align: center;
    margin-top: 40px;
    color: #AAA;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}
.vn-results-footer .sep { color: #DDD; }
.vn-results-footer strong { color: #666; }

/* --- MODAL (HISTORY) --- */
.vn-modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.2s ease;
}
.vn-modal-overlay.hidden { opacity: 0; pointer-events: none; }

.vn-modal {
    background: white;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    border-radius: var(--radius-std);
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(1);
    transition: transform 0.2s ease;
}
.vn-modal-overlay.hidden .vn-modal { transform: scale(0.95); }

.vn-modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--vn-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.vn-modal-header h3 { font-size: 20px; font-weight: 700; margin: 0; color: #111; }
.vn-modal-close { background: none; border: none; font-size: 24px; color: #999; cursor: pointer; }

.vn-modal-body { flex: 1; overflow-y: auto; padding: 0; }

.vn-history-table-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    padding: 12px 24px;
    background: #FAFAFA;
    border-bottom: 1px solid var(--vn-border);
    font-size: 12px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
}
.text-right { text-align: right; }

.vn-history-item {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    padding: 16px 24px;
    border-bottom: 1px solid var(--vn-border);
    font-size: 14px;
    color: #333;
}
.vn-history-item:last-child { border-bottom: none; }
.vn-h-date { font-weight: 500; color: #555; }
.vn-h-val { font-weight: 600; color: #111; }

.vn-history-empty { padding: 60px; text-align: center; color: #999; font-size: 14px; }

.vn-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--vn-border);
    text-align: right;
    background: #FAFAFA;
}

.vn-btn-danger-soft {
    background: #FFF0F0;
    border: 1px solid #FFCDD2;
    color: var(--vn-danger);
    font-family: var(--font-stack);
    font-weight: 600;
    font-size: 13px;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.vn-btn-danger-soft:hover { background: var(--vn-danger); color: white; border-color: var(--vn-danger); }

/* --- ANIMATION --- */
@keyframes fadeOutSlideUp { from { opacity: 1; transform: translateY(0); filter: blur(0); } to { opacity: 0; transform: translateY(-40px); filter: blur(10px); } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.vn-anim-exit { animation: fadeOutSlideUp 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }
.vn-fade-in-up { opacity: 0; animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }


/* =========================================
   MOBILE RESPONSIVENESS (AGGRESSIVE FIXES)
   ========================================= */
@media (max-width: 900px) {
    /* 1. Header */
    .vn-header { padding: 16px 20px; }
    
    /* 2. Active Test Scalability */
    .vn-value { font-size: 15vw; } /* Reduced from 18vw to 15vw for safety */
    .vn-hero { margin-bottom: 30px; }
    
    .vn-active-test {
        padding: 0 16px;
        min-height: auto; 
        height: 100dvh; 
    }
    
    /* 3. Dashboard Stacking */
    .vn-dashboard-container {
        grid-template-columns: 1fr; /* Force single column */
        gap: 24px; /* Reduced gap */
        margin-bottom: 20px;
        width: 100%;
        max-width: 100%;
    }
    .vn-results {
        padding: 40px 16px; /* Tighter padding on mobile */
    }
    
    /* 4. Results Typography */
    .vn-res-big { font-size: 36px; } /* Significantly smaller to prevent overflow */
    .vn-res-heading { font-size: 18px; }
    
    /* 5. Cards & Grids */
    .vn-cards-row {
        grid-template-columns: 1fr; /* Stack Download/Upload cards vertically */
        gap: 16px;
    }
    .vn-tech-card { padding: 16px; } /* Less padding in cards */
    
    .vn-net-grid {
        grid-template-columns: 1fr 1fr; /* 2x2 Grid for stats */
        gap: 10px;
    }
    .vn-net-item { padding: 12px; }
    .vn-net-item.full-width { grid-column: span 2; }
    .vn-val-md { font-size: 13px; }
    
    /* 6. Buttons */
    .vn-action-area { 
        flex-direction: column; 
        align-items: stretch; 
        gap: 12px;
    }
    .vn-btn-primary-action, .vn-btn-secondary {
        width: 100%;
        max-width: none;
        justify-content: center;
    }
    
    /* 7. Marketing Card */
    .vn-col-marketing { order: 2; } /* Put ads at bottom */
    
    /* 8. Modal on Mobile */
    .vn-modal { 
        width: 95%; 
        max-height: 90vh;
    }
    .vn-history-table-header, .vn-history-item {
        grid-template-columns: 1.5fr 1fr 1fr 1fr; /* Tighten date col */
        font-size: 11px;
        padding: 12px 8px; /* Tighter list padding */
    }
    .vn-h-date { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}