.hero-bg {
    background-image: radial-gradient(circle at 50% 30%, rgba(109, 40, 217, 0.08) 0%, rgba(249, 249, 255, 0) 50%);
}

.ambient-shadow {
    box-shadow: 0 10px 30px -10px rgba(83, 0, 183, 0.15);
}

/* ── Score ring animation ── */
.score-arc {
    animation: scoreReveal 1.2s ease-out forwards;
    transition: stroke-dashoffset 1.2s ease-out;
}

@keyframes scoreReveal {
    from { stroke-dashoffset: 376.99; }
}

/* ── Event row expand/collapse ── */
.event-row .event-detail { display: none; }
.event-row.expanded .event-detail { display: block; }
.event-row.expanded .expand-icon { transform: rotate(180deg); }

/* ── Spin animation for loading ── */
@keyframes spin {
    to { transform: rotate(360deg); }
}
.animate-spin {
    animation: spin 1s linear infinite;
}

/* ── Results section entrance ── */
#results-section {
    will-change: opacity, transform;
}

/* ── Subtle hover for small stat cards only ── */
#results-section .bg-white.rounded-xl {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
#results-section .results-header,
#results-section .bg-white.rounded-2xl {
    transition: border-color 0.2s ease;
}

/* ── Code block inside events ── */
#results-section pre {
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── Smooth scrollbar for results ── */
#results-section {
    scrollbar-width: thin;
    scrollbar-color: rgba(83, 0, 183, 0.2) transparent;
}
#results-section::-webkit-scrollbar { width: 6px; }
#results-section::-webkit-scrollbar-track { background: transparent; }
#results-section::-webkit-scrollbar-thumb { background: rgba(83, 0, 183, 0.2); border-radius: 3px; }

/* ── Results header ── */
.results-header {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}

/* ── Pulse dot ── */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ── Scan overlay ── */
.scan-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.scan-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.scan-card {
    background: white;
    border-radius: 1.5rem;
    box-shadow: 0 25px 60px -15px rgba(83, 0, 183, 0.3);
    width: 100%;
    max-width: 480px;
    padding: 2rem;
    transform: scale(0.95) translateY(20px);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.scan-overlay.active .scan-card {
    transform: scale(1) translateY(0);
}

/* Scan radar icon */
.scan-radar {
    position: relative;
    width: 72px;
    height: 72px;
    margin: 0 auto 1.5rem;
}
.scan-radar-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid rgba(83, 0, 183, 0.15);
}
.scan-radar-ring:nth-child(2) {
    inset: 8px;
}
.scan-radar-ring:nth-child(3) {
    inset: 16px;
}
.scan-radar-sweep {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(from 0deg, transparent 0deg, rgba(83, 0, 183, 0.25) 40deg, transparent 80deg);
    animation: radar-sweep 1.5s linear infinite;
}
@keyframes radar-sweep {
    to { transform: rotate(360deg); }
}
.scan-radar-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5300b7;
}

/* Scan steps */
.scan-steps {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    margin-bottom: 1.5rem;
}
.scan-step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    opacity: 0.3;
    transition: opacity 0.4s ease;
}
.scan-step.active {
    opacity: 1;
}
.scan-step.done {
    opacity: 0.6;
}

.scan-step-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
    transition: all 0.4s ease;
}
.scan-step .scan-step-icon {
    background: #f1f5f9;
    color: #94a3b8;
}
.scan-step.active .scan-step-icon {
    background: rgba(83, 0, 183, 0.1);
    color: #5300b7;
}
.scan-step.done .scan-step-icon {
    background: #dcfce7;
    color: #16a34a;
}

.scan-step-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: #334155;
    flex: 1;
}
.scan-step.active .scan-step-text {
    color: #0f172a;
}
.scan-step.done .scan-step-text {
    color: #64748b;
}

.scan-step-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(83, 0, 183, 0.2);
    border-top-color: #5300b7;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.scan-step.active .scan-step-spinner {
    opacity: 1;
}

/* Progress bar */
.scan-progress-track {
    height: 4px;
    background: #f1f5f9;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 1rem;
}
.scan-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #5300b7, #a855f7);
    border-radius: 999px;
    width: 0%;
    transition: width 0.5s ease;
}

.scan-url-display {
    text-align: center;
    font-size: 0.8125rem;
    color: #94a3b8;
    font-family: monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 1rem;
}

.scan-error-card {
    position: relative;
    display: grid;
    grid-template-columns: 210px minmax(0, 1fr);
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid rgba(109, 40, 217, 0.14);
    border-radius: 1.5rem;
    box-shadow: 0 24px 70px -32px rgba(83, 0, 183, 0.35), 0 12px 28px -22px rgba(15, 23, 42, 0.3);
}

.scan-error-visual {
    position: relative;
    min-height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #f5f0ff 0%, #fdf7ff 50%, #fff7ed 100%);
    border-right: 1px solid rgba(109, 40, 217, 0.08);
}

.scan-error-visual::before,
.scan-error-visual::after {
    content: '';
    position: absolute;
    border-radius: 999px;
    filter: blur(2px);
}

.scan-error-visual::before {
    width: 160px;
    height: 160px;
    top: -65px;
    left: -55px;
    background: rgba(168, 85, 247, 0.13);
}

.scan-error-visual::after {
    width: 120px;
    height: 120px;
    right: -45px;
    bottom: -45px;
    background: rgba(251, 146, 60, 0.12);
}

.scan-error-icon {
    position: relative;
    z-index: 2;
    width: 82px;
    height: 82px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6d28d9;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(109, 40, 217, 0.14);
    border-radius: 1.5rem;
    box-shadow: 0 18px 40px -20px rgba(83, 0, 183, 0.55);
    transform: rotate(-3deg);
}

.scan-error-icon .material-symbols-outlined {
    font-size: 2.35rem;
    font-variation-settings: 'FILL' 1;
}

.scan-error-orbit {
    position: absolute;
    z-index: 1;
    border: 1px solid rgba(109, 40, 217, 0.13);
    border-radius: 999px;
    animation: errorOrbit 8s linear infinite;
}

.scan-error-orbit::after {
    content: '';
    position: absolute;
    top: 50%;
    left: -4px;
    width: 8px;
    height: 8px;
    margin-top: -4px;
    border-radius: 50%;
    background: #a855f7;
    box-shadow: 0 0 0 5px rgba(168, 85, 247, 0.1);
}

.scan-error-orbit-one {
    width: 126px;
    height: 126px;
}

.scan-error-orbit-two {
    width: 174px;
    height: 174px;
    animation-direction: reverse;
    animation-duration: 12s;
}

.scan-error-orbit-two::after {
    right: -3px;
    left: auto;
    width: 6px;
    height: 6px;
    background: #fb923c;
    box-shadow: 0 0 0 4px rgba(251, 146, 60, 0.1);
}

.scan-error-content {
    min-width: 0;
    padding: 2.25rem 2.5rem;
}

.scan-error-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.8rem;
    color: #7c3aed;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.scan-error-eyebrow .material-symbols-outlined {
    font-size: 1rem;
    font-variation-settings: 'FILL' 1;
}

.scan-error-content h3 {
    margin: 0;
    color: #0f172a;
    font-family: 'Sora', system-ui, sans-serif;
    font-size: clamp(1.4rem, 3vw, 1.75rem);
    font-weight: 750;
    line-height: 1.25;
    letter-spacing: -0.025em;
}

.scan-error-guidance {
    max-width: 34rem;
    margin: 0.65rem 0 1.35rem;
    color: #64748b;
    font-size: 0.94rem;
    line-height: 1.65;
}

.scan-error-form label {
    display: block;
    margin-bottom: 0.45rem;
    color: #334155;
    font-size: 0.76rem;
    font-weight: 700;
}

.scan-error-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0 0.9rem;
    background: #f8fafc;
    border: 1px solid #dbe2ea;
    border-radius: 0.8rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.scan-error-input-wrap:focus-within {
    background: #ffffff;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 4px rgba(109, 40, 217, 0.1);
}

.scan-error-input-wrap:has(input[aria-invalid="true"]) {
    border-color: #e11d48;
    box-shadow: 0 0 0 4px rgba(225, 29, 72, 0.08);
}

.scan-error-input-wrap > .material-symbols-outlined {
    flex: 0 0 auto;
    color: #94a3b8;
    font-size: 1.15rem;
}

.scan-error-input-wrap input {
    width: 100%;
    min-width: 0;
    padding: 0.78rem 0;
    color: #0f172a;
    background: transparent;
    border: 0;
    outline: 0;
    box-shadow: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.scan-error-input-wrap input:focus {
    border: 0;
    outline: 0;
    box-shadow: none;
    --tw-ring-shadow: 0 0 #0000;
}

.scan-error-validation {
    margin: 0.45rem 0 0;
    color: #be123c;
    font-size: 0.76rem;
    font-weight: 600;
}

.scan-error-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

.scan-error-retry,
.scan-error-back {
    min-height: 42px;
    border-radius: 0.75rem;
    font-size: 0.86rem;
    font-weight: 700;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.scan-error-retry {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.65rem 1.1rem;
    color: #ffffff;
    background: linear-gradient(135deg, #5300b7, #7c3aed);
    border: 0;
    box-shadow: 0 10px 22px -12px rgba(83, 0, 183, 0.75);
}

.scan-error-retry .material-symbols-outlined {
    font-size: 1.05rem;
}

.scan-error-retry:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 26px -12px rgba(83, 0, 183, 0.8);
}

.scan-error-back {
    padding: 0.65rem 0.9rem;
    color: #64748b;
    background: transparent;
    border: 0;
}

.scan-error-back:hover {
    color: #334155;
    background: #f1f5f9;
}

.scan-error-retry:focus-visible,
.scan-error-back:focus-visible {
    outline: 3px solid rgba(124, 58, 237, 0.3);
    outline-offset: 2px;
}

.scan-error-detail {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    margin-top: 1.35rem;
    padding-top: 1rem;
    color: #94a3b8;
    border-top: 1px solid #f1f5f9;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.72rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.scan-error-detail > .material-symbols-outlined {
    flex: 0 0 auto;
    margin-top: 0.05rem;
    font-size: 0.95rem;
}

.scan-error-detail strong {
    display: block;
    margin-bottom: 0.15rem;
    color: #64748b;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

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

@media (max-width: 640px) {
    .scan-error-card {
        grid-template-columns: 1fr;
        border-radius: 1.25rem;
    }

    .scan-error-visual {
        min-height: 142px;
        border-right: 0;
        border-bottom: 1px solid rgba(109, 40, 217, 0.08);
    }

    .scan-error-icon {
        width: 66px;
        height: 66px;
        border-radius: 1.2rem;
    }

    .scan-error-icon .material-symbols-outlined {
        font-size: 2rem;
    }

    .scan-error-orbit-one {
        width: 104px;
        height: 104px;
    }

    .scan-error-orbit-two {
        width: 138px;
        height: 138px;
    }

    .scan-error-content {
        padding: 1.6rem 1.25rem 1.4rem;
    }

    .scan-error-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .scan-error-retry,
    .scan-error-back {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .scan-error-orbit {
        animation: none;
    }

    .scan-error-retry,
    .scan-error-back,
    .scan-error-input-wrap {
        transition: none;
    }
}
