/* NEOLIFA Skin Scan - Core UI */
#nsi-app-container {
    --nsi-ink: #20252d;
    --nsi-muted: #68707c;
    --nsi-soft: #f7f4ef;
    --nsi-paper: #ffffff;
    --nsi-line: rgba(32, 37, 45, 0.12);
    --nsi-accent: #42b7aa;
    --nsi-accent-dark: #177b73;
    --nsi-warm: #d9b573;
    --nsi-shadow: 0 24px 70px rgba(22, 28, 35, 0.16);
    color: var(--nsi-ink);
    font-family: "Plus Jakarta Sans", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#nsi-app-container *,
#nsi-app-container *::before,
#nsi-app-container *::after {
    box-sizing: border-box;
}

.nsi-desktop {
    align-items: center;
    background:
        radial-gradient(circle at 20% 20%, rgba(66, 183, 170, 0.16), transparent 28%),
        linear-gradient(135deg, #fbfaf7 0%, #f1eee8 100%);
    border: 1px solid var(--nsi-line);
    border-radius: 8px;
    box-shadow: var(--nsi-shadow);
    display: flex;
    gap: clamp(28px, 5vw, 64px);
    justify-content: space-between;
    margin: 24px auto;
    max-width: 980px;
    min-height: 420px;
    overflow: hidden;
    padding: clamp(28px, 6vw, 72px);
    position: relative;
}

.nsi-desktop::after {
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7));
    content: "";
    inset: 0 0 0 auto;
    pointer-events: none;
    position: absolute;
    width: 34%;
}

.nsi-desktop-copy {
    max-width: 520px;
    position: relative;
    z-index: 1;
}

.nsi-kicker {
    color: var(--nsi-accent-dark);
    display: inline-block;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    margin-bottom: 12px;
    text-transform: uppercase;
}

.nsi-desktop h2 {
    color: var(--nsi-ink);
    font-size: clamp(34px, 5vw, 58px);
    line-height: 1.02;
    margin: 0 0 18px;
    max-width: 12ch;
}

.nsi-desktop p {
    color: var(--nsi-muted);
    font-size: 17px;
    line-height: 1.65;
    margin: 0;
    max-width: 44ch;
}

.nsi-qr-panel {
    align-items: center;
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    box-shadow: 0 18px 45px rgba(20, 28, 36, 0.12);
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
    position: relative;
    z-index: 1;
}

.nsi-qr-panel img {
    background: #fff;
    border-radius: 6px;
    display: block;
    height: 260px;
    width: 260px;
}

.nsi-qr-panel span {
    color: var(--nsi-muted);
    font-size: 13px;
    font-weight: 700;
}

.nsi-mobile {
    display: none;
}

#nsi-camera-wrapper {
    background: #050708;
    height: 100svh;
    min-height: 620px;
    overflow: hidden;
    position: relative;
    width: 100%;
}

#nsi-video,
#nsi-canvas {
    height: 100%;
    inset: 0;
    object-fit: cover;
    position: absolute;
    transform: scaleX(-1);
    width: 100%;
}

#nsi-video {
    z-index: 1;
}

#nsi-canvas {
    display: none;
    z-index: 2;
}

#nsi-canvas.is-dimmed {
    filter: blur(2px) saturate(0.85);
    opacity: 0.32;
}

#nsi-camera-wrapper::before {
    background:
        linear-gradient(180deg, rgba(3, 5, 7, 0.74), transparent 26%, transparent 58%, rgba(3, 5, 7, 0.8)),
        radial-gradient(ellipse at center, transparent 38%, rgba(0, 0, 0, 0.44) 76%);
    content: "";
    inset: 0;
    pointer-events: none;
    position: absolute;
    z-index: 4;
}

#nsi-scan-overlay {
    display: none;
    inset: 0;
    pointer-events: none;
    position: absolute;
    z-index: 6;
}

#nsi-scan-overlay.is-active {
    display: block;
}

.nsi-face-frame {
    border: 2px solid rgba(255, 255, 255, 0.62);
    border-radius: 50%;
    height: min(58vh, 460px);
    left: 50%;
    max-width: 78vw;
    position: absolute;
    top: 43%;
    transform: translate(-50%, -50%);
    width: min(72vw, 360px);
}

.nsi-face-frame::before,
.nsi-face-frame::after {
    background: var(--nsi-warm);
    content: "";
    height: 2px;
    position: absolute;
    top: 50%;
    width: 34px;
}

.nsi-face-frame::before {
    left: -18px;
}

.nsi-face-frame::after {
    right: -18px;
}

.nsi-mesh {
    animation: meshPulse 4.7s ease-in-out infinite;
    background-image:
        linear-gradient(rgba(66, 183, 170, 0.3) 1px, transparent 1px),
        linear-gradient(90deg, rgba(66, 183, 170, 0.3) 1px, transparent 1px);
    background-size: 22px 22px;
    height: min(58vh, 460px);
    left: 50%;
    mask-image: radial-gradient(ellipse at center, black 44%, transparent 70%);
    max-width: 78vw;
    position: absolute;
    top: 43%;
    transform: translate(-50%, -50%);
    width: min(72vw, 360px);
    -webkit-mask-image: radial-gradient(ellipse at center, black 44%, transparent 70%);
}

.nsi-scan-beam {
    animation: beamScan 4.5s linear infinite;
    background: var(--nsi-accent);
    box-shadow: 0 0 18px var(--nsi-accent), 0 0 48px rgba(66, 183, 170, 0.52);
    height: 3px;
    left: 10%;
    position: absolute;
    width: 80%;
}

.nsi-scan-points {
    background: #fff;
    border: 2px solid var(--nsi-accent);
    border-radius: 999px;
    box-shadow: 0 0 18px rgba(66, 183, 170, 0.8);
    height: 12px;
    position: absolute;
    width: 12px;
}

.point-1 { left: 32%; top: 32%; }
.point-2 { right: 32%; top: 34%; }
.point-3 { left: 38%; top: 52%; }
.point-4 { right: 38%; top: 58%; }

#nsi-ui-layer {
    align-items: center;
    bottom: max(22px, env(safe-area-inset-bottom));
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 10px;
    left: 0;
    padding: 0 20px;
    position: absolute;
    text-align: center;
    width: 100%;
    z-index: 10;
}

.nsi-status-pill {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
    font-weight: 800;
    padding: 8px 12px;
}

#nsi-feedback-text {
    font-size: clamp(21px, 6vw, 30px);
    font-weight: 800;
    line-height: 1.18;
    margin: 0;
    max-width: 560px;
    text-shadow: 0 2px 18px rgba(0, 0, 0, 0.36);
    width: 100%;
}

#nsi-helper-text {
    color: rgba(255, 255, 255, 0.78);
    font-size: 14px;
    line-height: 1.45;
    margin: 0;
    max-width: 340px;
}

#nsi-countdown-text {
    font-size: 80px;
    font-weight: 900;
    line-height: 1;
    margin: 4px 0 0;
    min-height: 86px;
    text-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}

.nsi-fallback-screen {
    align-items: center;
    background: linear-gradient(180deg, #fbfaf7, #eef5f3);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 24px;
    position: absolute;
    z-index: 20;
}

.nsi-fallback-card,
.nsi-result-card {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    box-shadow: var(--nsi-shadow);
    color: var(--nsi-ink);
    max-height: calc(100svh - 48px);
    max-width: 440px;
    overflow: auto;
    padding: 22px;
    text-align: left;
    width: min(100%, 440px);
}

.nsi-fallback-card h3,
.nsi-result-card h3 {
    color: var(--nsi-ink);
    font-size: 24px;
    line-height: 1.15;
    margin: 0 0 12px;
    text-shadow: none;
}

.nsi-fallback-card p,
.nsi-summary {
    color: var(--nsi-muted);
    font-size: 14px;
    line-height: 1.55;
    margin: 0 0 18px;
}

.nsi-primary-action,
.nsi-secondary-action {
    align-items: center;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    font-size: 14px;
    font-weight: 800;
    justify-content: center;
    min-height: 46px;
    padding: 12px 16px;
    text-decoration: none;
    width: 100%;
}

.nsi-primary-action {
    background: var(--nsi-ink);
    color: #fff;
}

.nsi-secondary-action {
    background: #eef2f1;
    color: var(--nsi-ink);
    margin-bottom: 10px;
}

.nsi-metrics {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 18px 0;
}

.nsi-metric {
    background: #f7f8f8;
    border: 1px solid var(--nsi-line);
    border-radius: 6px;
    padding: 10px;
}

.nsi-metric-top {
    align-items: center;
    display: flex;
    font-size: 12px;
    justify-content: space-between;
    margin-bottom: 8px;
}

.nsi-metric-top strong {
    color: var(--nsi-accent-dark);
}

.nsi-meter {
    background: #e3e7e7;
    border-radius: 999px;
    height: 7px;
    overflow: hidden;
}

.nsi-meter span {
    background: linear-gradient(90deg, var(--nsi-accent), var(--nsi-warm));
    border-radius: inherit;
    display: block;
    height: 100%;
}

.nsi-routine {
    border-top: 1px solid var(--nsi-line);
    display: grid;
    gap: 14px;
    margin-top: 18px;
    padding-top: 16px;
}

.nsi-routine h4 {
    color: var(--nsi-ink);
    font-size: 13px;
    margin: 0 0 8px;
}

.nsi-routine ul {
    color: var(--nsi-muted);
    font-size: 13px;
    line-height: 1.45;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nsi-routine li {
    padding-left: 16px;
    position: relative;
}

.nsi-routine li + li {
    margin-top: 6px;
}

.nsi-routine li::before {
    background: var(--nsi-accent);
    border-radius: 999px;
    content: "";
    height: 6px;
    left: 0;
    position: absolute;
    top: 7px;
    width: 6px;
}

.nsi-warning {
    background: #fff7e6;
    border: 1px solid rgba(217, 181, 115, 0.5);
    border-radius: 6px;
    color: #755a24;
    font-size: 12px;
    line-height: 1.45;
    margin: 0;
    padding: 10px;
}

@keyframes beamScan {
    0% { opacity: 0; top: 18%; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { opacity: 0; top: 68%; }
}

@keyframes meshPulse {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.94); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0.1; transform: translate(-50%, -50%) scale(1.04); }
}

@media (hover: hover) and (pointer: fine) {
    #nsi-desktop-view {
        display: flex;
    }

    #nsi-mobile-view {
        display: none;
    }
}

@media (hover: none) and (pointer: coarse) {
    #nsi-desktop-view {
        display: none;
    }

    #nsi-mobile-view {
        display: block;
    }
}

@media (max-width: 720px) {
    .nsi-desktop {
        flex-direction: column;
        min-height: auto;
        text-align: center;
    }

    .nsi-desktop h2,
    .nsi-desktop p {
        max-width: none;
    }

    .nsi-qr-panel img {
        height: 220px;
        width: 220px;
    }
}

@media (max-width: 380px) {
    .nsi-metrics {
        grid-template-columns: 1fr;
    }

    .nsi-fallback-card,
    .nsi-result-card {
        padding: 18px;
    }
}
