:root {
    --primary: #1cd685;
    --primary-strong: #35ee9b;
    --primary-soft: rgba(28, 214, 133, 0.14);
    --brand: #5b9df9;
    --brand-soft: rgba(91, 157, 249, 0.14);
    --danger: #e66b6b;
    --warning: #e5b364;
    --bg-0: #0c1014;
    --bg-1: #121820;
    --surface: rgba(255, 255, 255, 0.045);
    --surface-2: rgba(255, 255, 255, 0.075);
    --border: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.18);
    --text: rgba(255, 255, 255, 0.92);
    --text-secondary: rgba(255, 255, 255, 0.68);
    --text-muted: rgba(255, 255, 255, 0.54);
    --font-sans: "Hanken Grotesk", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "Spline Sans Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg-0); color-scheme: dark; }
html, body, #app { width: 100%; }
body {
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    color: var(--text);
    font: 15px/1.45 var(--font-sans);
    background:
        radial-gradient(800px 520px at 85% -10%, rgba(91, 157, 249, 0.1), transparent 60%),
        radial-gradient(560px 480px at -10% 85%, rgba(28, 214, 133, 0.07), transparent 65%),
        linear-gradient(155deg, var(--bg-1), var(--bg-0));
    background-attachment: fixed;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0.8rem; font-size: clamp(2rem, 9vw, 3.75rem); line-height: 1.02; letter-spacing: -0.045em; }
h2 { margin-bottom: 0.55rem; font-size: 1.45rem; letter-spacing: -0.02em; }
p { color: var(--text-secondary); }

.app-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-rows: auto 1fr auto;
}
.app-header {
    min-height: 4.5rem;
    padding: max(0.8rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.8rem max(1rem, env(safe-area-inset-left));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
    background: rgba(8, 11, 15, 0.78);
    backdrop-filter: blur(18px);
    position: sticky;
    top: 0;
    z-index: 20;
}
.brand { display: inline-flex; align-items: center; gap: 0.6rem; min-width: 0; }
.brand img { width: 38px; height: 28px; object-fit: contain; }
.brand span { display: grid; line-height: 1; }
.brand small { color: var(--primary); text-transform: uppercase; letter-spacing: 0.17em; font-size: 0.62rem; font-weight: 700; }
.brand strong { margin-top: 0.2rem; font-size: 1rem; }
.identity-actions { display: flex; align-items: center; gap: 0.45rem; min-width: 0; }
.identity-chip {
    min-height: 2.65rem;
    max-width: 42vw;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.35rem 0.65rem;
    color: var(--text-secondary);
    background: var(--surface);
}
.identity-chip span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 12px var(--primary); flex: 0 0 auto; }
.logout-button {
    min-height: 2.65rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
    color: var(--text-secondary);
    background: var(--surface);
    cursor: pointer;
}
.app-content { width: min(100%, 980px); margin: 0 auto; padding: clamp(1.25rem, 4vw, 2.5rem) max(1rem, env(safe-area-inset-right)) 2rem max(1rem, env(safe-area-inset-left)); }
.app-footer {
    padding: 1rem max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    font-size: 0.72rem;
}
.app-footer a { color: var(--brand); }

.eyebrow {
    display: inline-block;
    margin-bottom: 0.65rem;
    color: var(--primary);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}
.hero-shell, .login-shell, .demo-shell { padding-top: clamp(1rem, 7vh, 4.5rem); }
.hero-copy { max-width: 720px; }
.hero-copy p { max-width: 58ch; font-size: 1.05rem; }
.primary-action {
    margin: clamp(1.5rem, 5vw, 2.5rem) 0;
    min-height: 5.25rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.9rem;
    padding: 0.95rem 1.1rem;
    border: 1px solid rgba(28, 214, 133, 0.36);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(28, 214, 133, 0.19), rgba(28, 214, 133, 0.08));
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}
.primary-action strong, .primary-action small { display: block; }
.primary-action strong { font-size: 1.02rem; }
.primary-action small { margin-top: 0.1rem; color: var(--text-secondary); }
.action-icon { width: 2.75rem; height: 2.75rem; border-radius: 12px; display: grid; place-items: center; background: var(--primary); color: #082116; font: 700 1.55rem var(--font-mono); }
.trust-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem; }
.trust-grid article, .glass-panel {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
    backdrop-filter: blur(12px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.2);
}
.trust-grid strong { display: block; margin-bottom: 0.3rem; }
.trust-grid p { margin-bottom: 0; font-size: 0.84rem; }
.trust-icon { display: inline-block; margin-bottom: 1rem; color: var(--brand); font: 600 0.72rem var(--font-mono); }

.login-shell { width: min(100%, 570px); margin: 0 auto; text-align: center; }
.login-shell h1 { font-size: clamp(2rem, 8vw, 3.2rem); }
.login-shell p { margin-inline: auto; max-width: 52ch; }
.login-mark { width: 92px; height: 92px; margin: 0 auto 1.5rem; display: grid; place-items: center; border: 1px solid rgba(28, 214, 133, 0.3); border-radius: 25px; background: var(--primary-soft); box-shadow: 0 18px 55px rgba(28, 214, 133, 0.1); }
.login-mark img { width: 68px; }
.google-button, .primary-button, .secondary-button {
    min-height: 3rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    border-radius: 12px;
    padding: 0.72rem 1rem;
    font-weight: 650;
    cursor: pointer;
}
.google-button { width: min(100%, 360px); margin: 1.2rem auto 0.75rem; color: #18212b; background: #fff; border: 0; }
.google-g { color: #4285f4; font: 700 1.15rem Arial, sans-serif; }
.login-note { display: block; color: var(--text-muted); }
.auth-failed-shell .result-mark.failure { color: white; background: var(--danger); }
.auth-failed-shell .text-button { display: inline-flex; margin-top: 0.25rem; }
.primary-button { border: 1px solid rgba(28, 214, 133, 0.35); background: var(--primary); color: #082116; }
.secondary-button { border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); }
.text-button { border: 0; padding: 0.75rem; color: var(--brand); background: transparent; cursor: pointer; }

.scanner-shell { width: min(100%, 660px); margin: 0 auto; }
.scanner-heading { text-align: center; }
.scanner-heading h1 { font-size: clamp(2rem, 8vw, 3rem); }
.scanner-heading p { margin-bottom: 1.2rem; }
.camera-shell { position: relative; aspect-ratio: 3 / 4; max-height: 68vh; overflow: hidden; border: 1px solid var(--border-strong); border-radius: 24px; background: #050709; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45); }
.camera-shell video { width: 100%; height: 100%; object-fit: cover; }
.camera-shade { position: absolute; inset: 0; background: radial-gradient(circle at center, transparent 0 29%, rgba(0, 0, 0, 0.46) 55%); pointer-events: none; }
.scan-frame { position: absolute; width: min(66%, 310px); aspect-ratio: 1; inset: 50% auto auto 50%; translate: -50% -50%; }
.scan-frame i { position: absolute; width: 34px; height: 34px; border-color: var(--primary); filter: drop-shadow(0 0 8px rgba(28, 214, 133, 0.5)); }
.scan-frame i:nth-child(1) { inset: 0 auto auto 0; border-top: 3px solid var(--primary); border-left: 3px solid var(--primary); border-radius: 11px 0 0; }
.scan-frame i:nth-child(2) { inset: 0 0 auto auto; border-top: 3px solid var(--primary); border-right: 3px solid var(--primary); border-radius: 0 11px 0 0; }
.scan-frame i:nth-child(3) { inset: auto auto 0 0; border-bottom: 3px solid var(--primary); border-left: 3px solid var(--primary); border-radius: 0 0 0 11px; }
.scan-frame i:nth-child(4) { inset: auto 0 0 auto; border-bottom: 3px solid var(--primary); border-right: 3px solid var(--primary); border-radius: 0 0 11px; }
.camera-message { position: absolute; inset: auto 1rem 1rem; padding: 0.8rem; display: flex; align-items: center; justify-content: center; gap: 0.6rem; border: 1px solid var(--border); border-radius: 12px; background: rgba(8, 11, 15, 0.88); backdrop-filter: blur(12px); text-align: center; }
.camera-message span, .camera-message strong { display: block; }
.camera-error { flex-direction: column; color: var(--warning); }
.manual-code { margin-top: 0.75rem; text-align: center; }
.manual-form { display: grid; gap: 0.65rem; margin-top: 0.45rem; padding: 1rem; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); text-align: left; }
.manual-form label { color: var(--text-secondary); font-size: 0.78rem; }
.manual-form input { min-height: 3.25rem; width: 100%; border: 1px solid var(--border-strong); border-radius: 11px; padding: 0.65rem 0.8rem; color: var(--text); background: rgba(0, 0, 0, 0.25); font: 600 1.15rem var(--font-mono); text-transform: uppercase; letter-spacing: 0.12em; }
.state-panel, .result-panel { margin-top: clamp(1rem, 8vh, 5rem); padding: clamp(1.3rem, 5vw, 2.2rem); text-align: center; }
.state-panel h1, .result-panel h1 { font-size: clamp(2rem, 8vw, 3rem); }
.status-orb { width: 16px; height: 16px; display: inline-block; margin-bottom: 1.2rem; border-radius: 50%; box-shadow: 0 0 24px currentColor; }
.status-orb.warning { color: var(--warning); background: currentColor; }
.result-mark { width: 76px; height: 76px; margin: 0 auto 1.2rem; display: grid; place-items: center; border-radius: 50%; font-size: 2.4rem; font-weight: 700; }
.result-panel.success .result-mark { color: #082116; background: var(--primary); box-shadow: 0 0 45px rgba(28, 214, 133, 0.25); }
.result-panel.failure .result-mark { color: white; background: var(--danger); }
.request-summary { margin: 1.3rem 0; padding: 0.9rem; display: grid; gap: 0.15rem; border: 1px solid var(--border); border-radius: 12px; background: rgba(0, 0, 0, 0.18); }
.request-summary span { color: var(--text-secondary); font-size: 0.82rem; }

.demo-heading { max-width: 700px; }
.demo-heading h1 { font-size: clamp(2rem, 7vw, 3.3rem); }
.demo-grid { display: grid; grid-template-columns: minmax(260px, 0.9fr) minmax(280px, 1.1fr); gap: 1rem; margin-top: 1.5rem; }
.qr-card, .demo-instructions { border: 1px solid var(--border); border-radius: 18px; background: var(--surface); }
.qr-card { padding: 1rem; display: grid; place-items: center; }
.qr-card img { display: block; width: min(100%, 390px); border-radius: 12px; }
.demo-instructions { padding: clamp(1.1rem, 4vw, 2rem); }
.demo-instructions ol { padding-left: 1.2rem; color: var(--text-secondary); }
.demo-instructions li { margin-bottom: 0.55rem; }
.status-pill { display: inline-flex; align-items: center; gap: 0.45rem; margin-bottom: 1rem; padding: 0.3rem 0.65rem; border: 1px solid var(--border); border-radius: 999px; color: var(--text-secondary); font-size: 0.75rem; }
.status-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); animation: pulse 1.4s infinite; }
.manual-code-display { margin: 1rem 0; padding: 0.8rem; display: grid; gap: 0.3rem; border: 1px solid var(--border); border-radius: 11px; background: rgba(0, 0, 0, 0.2); }
.manual-code-display span { color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; }
.manual-code-display strong { font: 600 1.4rem var(--font-mono); letter-spacing: 0.14em; }
.demo-success { margin-top: 1.5rem; text-align: center; padding: clamp(1.2rem, 5vw, 2.2rem); }
.demo-success h2 { font-size: 2rem; }
.token-preview { margin: 1rem 0; padding: 0.8rem; display: grid; gap: 0.4rem; overflow: hidden; border: 1px solid var(--border); border-radius: 11px; background: rgba(0, 0, 0, 0.25); text-align: left; }
.token-preview span { color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; }
.token-preview code { overflow-wrap: anywhere; color: var(--primary); font: 0.75rem var(--font-mono); }

.boot-shell, .center-state { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 1rem; color: var(--text-secondary); }
.boot-shell img { width: 82px; }
.boot-shell { width: 100%; padding: 1.5rem; overflow: hidden; text-align: center; }
.boot-shell.boot-failed strong { color: var(--text); font-size: 1.15rem; }
.boot-shell.boot-failed span { max-width: 28ch; }
.spinner { width: 24px; height: 24px; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
#blazor-error-ui { display: none; position: fixed; inset: auto 0 0; z-index: 100; padding: 0.8rem 1rem; align-items: center; gap: 0.8rem; color: #fff; background: var(--danger); }
#blazor-error-ui .reload { text-decoration: underline; }
#blazor-error-ui .dismiss { margin-left: auto; border: 0; color: #fff; background: transparent; font-size: 1.3rem; }

@keyframes spin { to { rotate: 360deg; } }
@keyframes pulse { 50% { opacity: 0.35; } }

@media (max-width: 700px) {
    .trust-grid, .demo-grid { grid-template-columns: minmax(0, 1fr); }
    .hero-shell, .login-shell, .demo-shell { padding-top: 0.75rem; }
    .identity-chip { display: none; }
    .camera-shell { max-height: 62vh; }
}

@media (max-width: 700px) {
    body:has(.boot-shell),
    body:has(.scanner-shell) {
        height: 100dvh;
        overflow: hidden;
        overscroll-behavior: none;
    }

    body:has(.scanner-shell) .app-shell {
        height: 100dvh;
        min-height: 0;
        grid-template-rows: auto minmax(0, 1fr);
    }

    body:has(.scanner-shell) .app-content {
        min-height: 0;
        width: 100%;
        padding: 0.7rem max(0.7rem, env(safe-area-inset-right))
            max(0.7rem, env(safe-area-inset-bottom))
            max(0.7rem, env(safe-area-inset-left));
        overflow: hidden;
    }

    body:has(.scanner-shell) .app-footer {
        display: none;
    }

    body:has(.scanner-shell) .scanner-shell {
        height: 100%;
        display: grid;
        grid-template-rows: auto minmax(0, 1fr) auto;
    }

    body:has(.scanner-shell) .scanner-heading h1 {
        margin-bottom: 0.35rem;
        font-size: 1.65rem;
    }

    body:has(.scanner-shell) .scanner-heading p {
        margin-bottom: 0.55rem;
        font-size: 0.82rem;
    }

    body:has(.scanner-shell) .camera-shell {
        min-height: 0;
        max-height: none;
        aspect-ratio: auto;
        border-radius: 18px;
    }

    body:has(.scanner-shell) .manual-code {
        margin-top: 0.25rem;
    }
}

@media (pointer: coarse) {
    .primary-button, .secondary-button, .google-button, .text-button, .logout-button { min-height: 44px; }
}

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