html,
body {
    margin: 0;
    overflow: hidden;
    background: #000;
    font-family: system-ui, Arial, sans-serif;
}

.ar-welcome-logo {
    width: 68px;
    height: 68px;

    display: flex;
    align-items: center;
    justify-content: center;

    margin-bottom: 14px;
    overflow: hidden;

    border-radius: 50%;
    background: rgba(22, 163, 74, .9);
    box-shadow: 0 15px 40px rgba(22, 163, 74, .3);

    text-decoration: none;
    transition: transform .15s ease;
}

.ar-welcome-logo img {
    width: 100%;
    height: 100%;
    display: block;

    object-fit: cover;
    border-radius: 50%;
}

.ar-welcome-logo:active {
    transform: scale(.96);
}

#status {
    position: fixed;
    top: max(8px, env(safe-area-inset-top));
    left: 10px;
    right: 10px;
    z-index: 30;
    color: #fff;
    background: rgba(15, 23, 42, .62);
    padding: 7px 10px;
    border-radius: 10px;
    font-size: 11px;
    line-height: 1.3;
    text-align: center;
    backdrop-filter: blur(8px);
    pointer-events: none;
}

#ui {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(80px + env(safe-area-inset-bottom));
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    pointer-events: none;
}

#ui button {
    pointer-events: auto;
    border: 0;
    border-radius: 10px;
    min-width: 38px;
    height: 36px;
    padding: 0 8px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    color: #fff;
    background: rgba(15, 23, 42, .78);
    backdrop-filter: blur(8px);
}

#ui button.primary {
    background: rgba(22, 163, 74, .9);
}

#ui button.danger {
    background: rgba(220, 38, 38, .9);
}

#ui .control {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 5px;

    height: 36px;
    padding: 0 8px;
    box-sizing: border-box;

    border-radius: 10px;
    font-size: 10px;
    color: #fff;

    background: rgba(15, 23, 42, .78);
    backdrop-filter: blur(8px);
}

#ui .control input {
    width: 54px;
    height: 14px;
    margin: 0;
}

#ui {
    flex-wrap: wrap;
    row-gap: 6px;
}

#tilePicker {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(126px + env(safe-area-inset-bottom));
    z-index: 31;
    pointer-events: auto;
}

#tileSearch {
    width: 100%;
    height: 32px;
    border: 0;
    border-radius: 10px;
    padding: 0 12px;
    margin-bottom: 5px;
    color: white;
    background: rgba(15, 23, 42, .72);
    backdrop-filter: blur(8px);
    font-size: 12px;
    outline: none;
}

#tileSearch::placeholder {
    color: rgba(255, 255, 255, .7);
}

#tileScroller {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    padding: 2px 1px 4px;
    scrollbar-width: none;
}

#tileScroller::-webkit-scrollbar {
    display: none;
}

.tile-item {
    flex: 0 0 auto;
    width: 56px;
    height: 68px;
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 4px;
    background: rgba(15, 23, 42, .72);
    color: white;
    backdrop-filter: blur(8px);
}

.tile-item.active {
    border-color: #22c55e;
    background: rgba(22, 163, 74, .35);
}

.tile-item img {
    width: 100%;
    height: 40px;
    object-fit: cover;
    border-radius: 7px;
    display: block;
}

#ui button.capture {
    background: rgba(37, 99, 235, .92);
    font-size: 15px;
}

.tile-item span {
    display: block;
    margin-top: 3px;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

button#ARButton {
    position: fixed !important;
    left: 50% !important;
    right: auto !important;
    top: auto !important;
    bottom: calc(28px + env(safe-area-inset-bottom)) !important;

    transform: translateX(-50%) !important;

    min-width: 190px !important;
    min-height: 48px !important;
    padding: 10px 20px !important;

    border: 0 !important;
    border-radius: 999px !important;

    color: #052e16 !important;
    background: linear-gradient(135deg, #22c55e, #4ade80) !important;

    font-size: 13px !important;
    font-weight: 900 !important;
    white-space: nowrap !important;

    box-shadow: 0 14px 38px rgba(34, 197, 94, .38) !important;
    z-index: 50 !important;
}

.lead-modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(0, 0, 0, .58);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.lead-modal.hidden {
    display: none;
}

.lead-box {
    width: 100%;
    max-width: 320px;
    box-sizing: border-box;
    background: #fff;
    color: #111827;
    border-radius: 18px;
    padding: 18px;
    text-align: center;
}

.lead-box h3 {
    margin: 0 0 6px;
}

.lead-box p {
    margin: 0 0 12px;
    font-size: 13px;
    color: #6b7280;
}

.lead-box input {
    width: 100%;
    height: 42px;
    box-sizing: border-box;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 0 12px;
    margin-bottom: 10px;
    font-size: 15px;
}

#status,
#tilePicker,
#ui {
    transition:
        opacity .2s ease,
        visibility .2s ease;
}

.lead-box button {
    width: 100%;
    height: 42px;
    border: 0;
    border-radius: 12px;
    margin-top: 8px;
    font-weight: 800;
    background: #16a34a;
    color: white;
}

.lead-box button.muted {
    background: #e5e7eb;
    color: #111827;
}

/* =========================================================
   HƯỚNG DẪN KHI MỚI MỞ TRANG AR
========================================================= */

#arWelcome {
    position: fixed;
    inset: 0;
    z-index: 35;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    padding:
        max(24px, env(safe-area-inset-top)) 22px max(100px, calc(90px + env(safe-area-inset-bottom)));

    box-sizing: border-box;
    color: #fff;
    text-align: center;

    background:
        radial-gradient(circle at center,
            rgba(22, 163, 74, .16),
            rgba(0, 0, 0, .94) 65%);

    transition:
        opacity .25s ease,
        visibility .25s ease;

    pointer-events: auto;
}

#arWelcome.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#arWelcome.hidden {
    opacity: 0;
    visibility: hidden;
}

.ar-welcome-icon {
    width: 68px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    border-radius: 20px;
    font-size: 32px;
    background: rgba(22, 163, 74, .9);
    box-shadow: 0 15px 40px rgba(22, 163, 74, .3);
}

#arWelcome h1 {
    margin: 0;
    font-size: 22px;
    line-height: 1.25;
    font-weight: 900;
}

#arWelcome>p {
    max-width: 330px;
    margin: 10px 0 18px;
    color: rgba(255, 255, 255, .78);
    font-size: 13px;
    line-height: 1.5;
}

.ar-welcome-steps {
    width: 100%;
    max-width: 340px;
    display: grid;
    gap: 8px;
    text-align: left;
}

.ar-welcome-steps>div {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 12px;
    color: rgba(255, 255, 255, .86);
    background: rgba(15, 23, 42, .72);
    backdrop-filter: blur(8px);
    font-size: 12px;
    line-height: 1.4;
}

.ar-welcome-steps span {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    color: #052e16;
    background: #4ade80;
    font-size: 11px;
    font-weight: 900;
}

/*
|--------------------------------------------------------------------------
| Trạng thái trước khi mở AR
|--------------------------------------------------------------------------
*/

body:not(.ar-session-active) #status,
body:not(.ar-session-active) #tilePicker,
body:not(.ar-session-active) #ui {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/*
|--------------------------------------------------------------------------
| Trạng thái khi camera AR đang hoạt động
|--------------------------------------------------------------------------
*/

body.ar-session-active #status,
body.ar-session-active #tilePicker,
body.ar-session-active #ui {
    opacity: 1;
    visibility: visible;
}

body.ar-session-active button#ARButton {
    display: none !important;
}

@media (max-height: 650px) {
    .ar-welcome-icon {
        width: 52px;
        height: 52px;
        margin-bottom: 9px;
        font-size: 25px;
        border-radius: 16px;
    }

    #arWelcome h1 {
        font-size: 18px;
    }

    #arWelcome>p {
        margin: 7px 0 10px;
        font-size: 12px;
    }

    .ar-welcome-steps {
        gap: 5px;
    }

    .ar-welcome-steps>div {
        padding: 7px 9px;
        font-size: 11px;
    }

    button#ARButton {
        min-height: 44px !important;
        bottom: calc(14px + env(safe-area-inset-bottom)) !important;
    }
}