/* ==========================
   UPLOAD
========================== */

.upload-main {
    width: 100%;
    padding: 0 16px 80px;
}

.upload-shell {
    max-width: 1340px;
}

.upload-left-ad,
.upload-right-ad {
    margin-top: 94px;
}

.upload-page {
    max-width: 760px;
    width: 100%;
    margin: 0 auto;
    padding: 94px 0 0;
    min-width: 0;
}

/* ==========================
   SHARED LIQUID GLASS
========================== */

.drop-zone,
.field input,
.field select,
.submit-upload,
.upload-message {
    position: relative;
    overflow: hidden;

    background: rgba(255, 255, 255, .48);

    backdrop-filter: blur(38px) saturate(1.25);
    -webkit-backdrop-filter: blur(38px) saturate(1.25);

    border: 1px solid rgba(255, 255, 255, .42);

    box-shadow:
        0 18px 50px rgba(0, 0, 0, .12),
        inset 0 1px 0 rgba(255, 255, 255, .85),
        inset 0 -1px 0 rgba(255, 255, 255, .18);
}

.drop-zone::before,
.submit-upload::before,
.upload-message::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background:
        linear-gradient(
            to bottom,
            rgba(255, 255, 255, .42),
            rgba(255, 255, 255, .08) 42%,
            rgba(255, 255, 255, 0) 100%
        );
    pointer-events: none;
}

.drop-zone > *,
.submit-upload > *,
.upload-message > * {
    position: relative;
    z-index: 1;
}

/* ==========================
   CARD + HEADER
========================== */

.upload-card {
    padding: clamp(24px, 3vw, 32px);
}

.upload-header {
    text-align: center;
    margin-bottom: 20px;
}

.eyebrow {
    margin-bottom: 12px;

    font-size: 13px;
    font-weight: 850;
    letter-spacing: .13em;
    text-transform: uppercase;

    color: rgba(20, 20, 20, .55);
}

.upload-header h1,
.upload-header h2 {
    margin: 0;

    font-size: 42px;
    line-height: 1.1;
    font-weight: 850;

    color: #222;
}

.upload-subtitle {
    max-width: 560px;
    margin: 16px auto 0;

    font-size: 17px;
    line-height: 1.55;

    color: rgba(20, 20, 20, .68);
}

/* ==========================
   MODE TOGGLE + CAMERA
========================== */

.upload-mode-toggle {
    display: flex;
    width: min(100%, 360px);
    margin: 0 auto 22px;
}

.upload-mode-btn {
    margin: 0;
    padding: 11px 18px;
    border: 0;
    appearance: none;
    -webkit-appearance: none;

    font-family: inherit;
    line-height: 1.2;
    cursor: pointer;
}

.upload-mode-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.camera-panel {
    display: grid;
    gap: 14px;
}

/* Class display rules must not override the HTML hidden attribute. */
.camera-panel[hidden],
#filePanel[hidden] {
    display: none !important;
}

.upload-camera-stage {
    position: relative;
    overflow: hidden;
    border-radius: 22px;
    background: #111;
    aspect-ratio: 3 / 4;
    width: min(100%, 420px);
    margin-inline: auto;
    border: 1px solid rgba(255, 255, 255, .36);
    box-shadow: 0 14px 34px rgba(0, 0, 0, .13);
}

.upload-camera-stage video,
.upload-camera-stage canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-camera-stage video {
    transform: none;
}

.upload-camera-stage video.is-live {
    transform: scaleX(-1);
}

.upload-camera-stage canvas {
    transform: scaleX(-1);
    pointer-events: none;
}

.upload-verdict {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 2;
    padding: 10px 14px;
    border-radius: 14px;
    text-align: center;
    font-size: 14px;
    font-weight: 800;
    color: #fff;
    background: rgba(0, 0, 0, .55);
}

.upload-verdict.is-pass {
    background: rgba(28, 140, 70, .88);
}

.upload-verdict.is-fail {
    background: rgba(180, 40, 40, .88);
}

.upload-verdict.is-idle {
    background: rgba(0, 0, 0, .55);
}

.upload-camera-status {
    margin: 0;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    color: rgba(20, 20, 20, .68);
}

.upload-camera-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.camera-action-btn {
    margin-top: 0;
    padding: 12px 10px;
    font-size: 14px;
}

.camera-capture-preview {
    margin-top: 4px;
}

/* ==========================
   DROP ZONE
========================== */

.drop-zone {
    display: block;
    padding: 32px;

    border-radius: 26px;
    border-style: dashed;
    border-width: 2px;

    text-align: center;
    cursor: pointer;

    transition: .2s ease;
}

.drop-zone:hover,
.drop-zone.dragover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, .28);
    border-color: rgba(255, 255, 255, .72);

    box-shadow:
        0 22px 58px rgba(0, 0, 0, .15),
        inset 0 1px 0 rgba(255, 255, 255, .9),
        inset 0 -1px 0 rgba(255, 255, 255, .22);
}

#faceImage {
    display: none;
}

.empty-preview {
    display: flex;
    flex-direction: column;
    gap: 10px;

    font-size: 15px;
    font-weight: 750;

    color: rgba(20, 20, 20, .62);
}

.upload-icon {
    position: relative;
    width: 44px;
    height: 44px;
    margin-inline: auto;
    font-size: 0;
    color: rgba(20, 20, 20, .72);
}

.upload-icon::before,
.upload-icon::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 26px;
    height: 4px;
    border-radius: 999px;
    background: currentColor;
    transform: translate(-50%, -50%);
}

.upload-icon::after {
    transform: translate(-50%, -50%) rotate(90deg);
}

.image-preview {
    display: block;
    width: min(100%, 280px);
    margin: 0 auto;
    aspect-ratio: 3 / 4;
    object-fit: cover;

    border-radius: 20px;

    border: 1px solid rgba(255, 255, 255, .36);
    box-shadow: 0 14px 34px rgba(0, 0, 0, .13);
    cursor: pointer;
}

/* The class display rule must not override the native hidden state before a
   file is selected or a camera capture exists. */
.image-preview[hidden] {
    display: none !important;
}

/* ==========================
   FORM
========================== */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 26px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;

    font-size: 13px;
    font-weight: 850;

    color: rgba(20, 20, 20, .68);
}

.field input,
.field select {
    height: 48px;
    padding: 0 14px;

    border-radius: 16px;
    outline: none;

    font-size: 15px;
    font-family: inherit;

    color: #222;
}

.field input:focus,
.field select:focus {
    background: rgba(255, 255, 255, .30);
    border-color: rgba(255, 255, 255, .72);
}

.checkbox-row {
    display: flex;
    gap: 10px;
    margin-top: 22px;
    align-items: center;

    font-size: 14px;
    font-weight: 700;

    color: rgba(20, 20, 20, .68);
}

.checkbox-row input {
    width: 17px;
    height: 17px;
    accent-color: #222;
}

.upload-message {
    margin-top: 18px;
    min-height: 20px;
    padding: 12px 14px;

    border-radius: 18px;

    text-align: center;
    font-size: 14px;
    font-weight: 750;

    color: rgba(20, 20, 20, .70);
}

.upload-message:empty {
    display: none;
}

.submit-upload {
    width: 100%;
    margin-top: 22px;
    padding: 16px 28px;

    border-radius: 999px;

    cursor: pointer;

    font-size: 16px;
    font-weight: 850;
    font-family: inherit;

    color: #222;

    transition: .2s ease;
}

.submit-upload:hover:not(:disabled) {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, .34);
}

.submit-upload:disabled {
    opacity: .55;
    cursor: not-allowed;
}

@media (max-width: 700px) {
    .upload-main {
        padding: 0 16px 60px;
    }

    .upload-page {
        padding-top: 95px;
    }

    .upload-card {
        padding: 28px 22px;
    }

    .upload-header h1,
    .upload-header h2 {
        font-size: 34px;
    }

    .upload-subtitle {
        font-size: 16px;
    }

    .drop-zone {
        padding: 28px 20px;
    }

    .upload-camera-actions {
        grid-template-columns: 1fr;
    }
}

/* Phone Option B: the card takes spare visible height, while controls keep
   their own sizes. Content can extend the page on short screens/camera mode. */
@media (max-width: 600px) {
    .page-upload[data-ad-layout="responsive"] {
        /* Reserve the stable small viewport before first paint, capped by the
           initial visible area. CSS is the fallback without scripting. */
        --mobile-layout-viewport-unit: var(--upload-viewport-unit, 1svh);
        /* Compact the panel, never the ads, when browser chrome leaves less
           usable height. Above 760px of safe content space this is zero. */
        --upload-panel-pressure: clamp(0px, calc((760px - (var(--mobile-layout-viewport-unit) * 100
            - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px))) / 2), 64px);
        display: flex;
        flex-direction: column;
        min-height: calc(var(--mobile-layout-viewport-unit) * 100);
    }

    .page-upload .navbar { flex-shrink: 0; margin-top: 12px; }

    .page-upload[data-ad-layout="responsive"] .responsive-ads-shell {
        flex: 1 0 auto;
        min-height: 0;
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "top" "content" "right";
        /* Reserve both ad rows even while HTML is still arriving. Otherwise
           the form borrows the unparsed lower slot's height on first paint. */
        grid-template-rows: minmax(var(--compare-ad-height), auto)
            minmax(min-content, 1fr) minmax(var(--compare-ad-height), auto);
        align-items: stretch;
        gap: var(--compare-gap);
        padding: var(--compare-gap) var(--mobile-page-gutter)
            max(10px, calc(16px - var(--compare-compact-space) * .375), var(--compare-gap));
    }

    .page-upload .responsive-ads-shell [data-ad-slot="left"],
    .page-upload .upload-main > [data-ad-anchor="middle"] { display: none; }

    .page-upload .responsive-ads-shell > .site-ads-content,
    .page-upload .responsive-ads-shell .upload-main,
    .page-upload .upload-page {
        display: flex;
        flex-direction: column;
        min-width: 0;
        min-height: 0;
    }

    .page-upload .responsive-ads-shell .upload-main,
    .page-upload .upload-page {
        flex: 1 0 auto;
        padding: 0;
    }

    .page-upload .upload-card {
        --surface-radius: clamp(22px, 6vw, 30px);
        display: flex;
        flex-direction: column;
        flex: 1 0 auto;
        width: 100%;
        min-width: 0;
        gap: max(4px, calc(var(--compare-section-gap) - var(--upload-panel-pressure) * .05));
        padding: max(8px, calc(var(--compare-card-padding) - var(--upload-panel-pressure) * .05));
    }

    .page-upload .upload-header { flex-shrink: 0; margin-bottom: 0; }
    .page-upload .eyebrow { margin-bottom: max(3px, calc(var(--compare-control-gap) - var(--upload-panel-pressure) * .035)); font-size: clamp(10px, 2.5vw, 12px); line-height: 1.2; }
    .page-upload .upload-header :is(h1, h2) { font-size: max(28px, calc(clamp(34px, 8vw, 38px) - var(--upload-panel-pressure) * .1)); line-height: 1.05; }
    .page-upload .upload-subtitle { margin-top: max(3px, calc(var(--compare-control-gap) - var(--upload-panel-pressure) * .035)); font-size: clamp(16px, 3.8vw, 18px); line-height: max(1.2em, calc(1.25em - var(--upload-panel-pressure) * .02)); }

    .page-upload .upload-form {
        display: flex;
        flex-direction: column;
        flex: 1 0 auto;
        justify-content: space-between;
        gap: max(4px, calc(var(--compare-control-gap) - var(--upload-panel-pressure) * .03));
    }

    .page-upload .upload-form > * { flex-shrink: 0; }
    .page-upload .upload-mode-toggle {
        width: min(100%, 280px);
        height: max(48px, calc(clamp(52px, calc(var(--mobile-layout-viewport-unit) * 6.2), 56px) - var(--upload-panel-pressure) * .08));
        margin: 0 auto;
    }

    .page-upload .upload-mode-btn {
        padding: 0 14px;
        font-size: clamp(15px, 3.6vw, 16px);
    }

    .page-upload .drop-zone { display: flex; align-items: center; justify-content: center; height: max(88px, calc(clamp(140px, calc(var(--mobile-layout-viewport-unit) * 17), 170px) - var(--upload-panel-pressure))); padding: max(6px, calc(12px - var(--upload-panel-pressure) * .1)); transition: background .2s ease, border-color .2s ease, box-shadow .2s ease, transform .2s ease; }
    .page-upload .empty-preview { gap: max(3px, calc(6px - var(--upload-panel-pressure) * .05)); font-size: 14px; line-height: 1.25; }
    .page-upload .upload-icon { width: max(24px, calc(32px - var(--upload-panel-pressure) * .125)); height: max(24px, calc(32px - var(--upload-panel-pressure) * .125)); }
    .page-upload .drop-zone .image-preview { width: auto; height: 100%; max-width: 100%; object-fit: contain; border-radius: 12px; }
    .page-upload .checkbox-row { margin-top: 0; line-height: 1.35; }
    .page-upload .checkbox-row input { flex-shrink: 0; }
    .page-upload .upload-message { margin-top: 0; }
    .page-upload .submit-upload { height: clamp(52px, calc(var(--mobile-layout-viewport-unit) * 6), 58px); margin-top: 0; padding: 12px 20px; line-height: 1.2; transition: background .2s ease, border-color .2s ease, box-shadow .2s ease, transform .2s ease; }
    .page-upload #submitUpload { height: max(48px, calc(clamp(52px, calc(var(--mobile-layout-viewport-unit) * 6), 58px) - var(--upload-panel-pressure) * .08)); }

    /* Keep the 3:4 camera stage compact without changing capture geometry. */
    .page-upload .upload-camera-stage { width: min(68vw, 280px); max-width: 100%; margin-inline: auto; }
    .page-upload .camera-panel { gap: var(--compare-control-gap); }
    .page-upload .upload-camera-status { margin: 0; font-size: clamp(12px, 3.3vw, 14px); line-height: 1.25; }
    .page-upload .upload-camera-actions { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(52px, .6fr); gap: clamp(5px, 1.5vw, 8px); }
    .page-upload .camera-action-btn { margin: 0; padding: 0 clamp(4px, 1vw, 6px); font-size: clamp(12px, 3vw, 14px); white-space: nowrap; }
}

/* A quieter upload surface: one heading, one picker, one primary action. */
.page-upload .upload-header { text-align: left; margin-bottom: 24px; }
.page-upload .upload-header :is(h1, h2) { font-size: 36px; line-height: 1.15; letter-spacing: -.035em; font-weight: 750; color: #172c3d; }
.page-upload .upload-subtitle { max-width: none; margin: 10px 0 0; font-size: 16px; line-height: 1.5; color: #5c7080; }
.page-upload .upload-mode-toggle { width: 100%; max-width: none; margin: 0 0 16px; background: #e7eef2; border-color: #d8e2e8; }
.page-upload .upload-mode-btn { font-size: 14px; font-weight: 650; min-height: 42px; }
.page-upload .drop-zone { border: 1.5px dashed #afc7d6; border-radius: 22px; background: #edf5f9; box-shadow: inset 0 1px 2px rgba(255,255,255,.9); backdrop-filter: none; -webkit-backdrop-filter: none; }
.page-upload .drop-zone::before, .page-upload .submit-upload::before { content: none; }
.page-upload .drop-zone:hover, .page-upload .drop-zone.dragover { background: #e2f0f8; border-color: #4385ac; transform: none; box-shadow: none; }
.page-upload .drop-zone:focus-visible { outline: 3px solid #4385ac; outline-offset: 3px; }
.page-upload .empty-preview { gap: 8px; font-weight: 450; color: #6a7e8d; }
.page-upload .empty-preview strong { font-size: 18px; font-weight: 700; color: #224d69; }
.page-upload .empty-preview > span { font-size: 12px; line-height: 1.4; }
.page-upload .upload-icon { width: 36px; height: 36px; color: #5a89a6; margin: 0 auto 4px; flex-shrink: 0; }
.page-upload .drop-zone:has(.image-preview:not([hidden])) { border-style: solid; background: #e8f0f5; }
.page-upload .checkbox-row { font-size: 13px; font-weight: 450; line-height: 1.4; color: #526777; gap: 10px; margin-top: 18px; cursor: pointer; }
.page-upload .checkbox-row input { accent-color: #286c96; flex-shrink: 0; }
.page-upload #submitUpload { margin-top: 18px; min-height: 48px; border: 1px solid #a9cddd; background: #d8ecf7; color: #174b6d; font-size: 15px; font-weight: 700; box-shadow: 0 2px 4px rgba(30,70,100,.08), inset 0 1px 0 #fff; backdrop-filter: none; -webkit-backdrop-filter: none; }
.page-upload #submitUpload:hover:not(:disabled) { background: #c7e4f4; transform: none; }
.page-upload #submitUpload:disabled { opacity: 1; background: #e8eef2; border-color: #dce5ea; color: #81919c; box-shadow: none; }
.page-upload .upload-next { margin: 12px 0 0; font-size: 12px; line-height: 1.4; color: #687e8e; text-align: center; }
@media (min-width: 851px) {
    .page-upload .responsive-ads-shell .upload-card { padding: 36px 48px; }
    .page-upload .upload-header, .page-upload .upload-form { max-width: 560px; }
}
@media (max-width: 600px) {
    .page-upload .upload-card { padding: 18px; gap: 16px; }
    .page-upload .upload-header { margin: 0; }
    .page-upload .upload-header :is(h1, h2) { font-size: 30px; }
    .page-upload .upload-subtitle { margin-top: 6px; line-height: 1.4; }
    .page-upload .upload-form { gap: 12px; justify-content: flex-start; }
    .page-upload #filePanel { display: flex; flex: 1 0 auto; min-height: max(120px, calc(clamp(160px, calc(var(--mobile-layout-viewport-unit) * 22), 220px) - var(--upload-panel-pressure))); }
    .page-upload .upload-mode-toggle { height: 48px; margin: 0; }
    .page-upload .upload-mode-btn { min-height: 38px; font-size: 14px; }
    .page-upload .drop-zone { width: 100%; height: auto; min-height: 120px; padding: 12px; border-radius: 18px; }
    .page-upload .drop-zone .image-preview { height: clamp(140px, calc(var(--mobile-layout-viewport-unit) * 26), 240px); width: auto; max-width: 100%; }
    .page-upload .empty-preview { gap: 6px; }
    .page-upload .empty-preview strong { font-size: 17px; }
    .page-upload .upload-icon { width: 30px; height: 30px; margin-bottom: 2px; }
    .page-upload .upload-drop-hint { display: none; }
    .page-upload .checkbox-row { margin: 0; font-size: 12px; }
    .page-upload #submitUpload { margin: 0; height: 48px; padding: 12px 20px; }
    .page-upload .upload-next { margin: 0; font-size: 11px; }
    .page-upload .camera-action-btn { font-size: 12px; padding-inline: 3px; letter-spacing: -.015em; }
}
@media (max-width: 600px) and (max-height: 740px) {
    .page-upload .upload-card { padding: 12px; gap: 10px; }
    .page-upload .upload-header :is(h1, h2) { font-size: 28px; line-height: 1.1; }
    .page-upload .upload-subtitle { line-height: 1.3; }
    .page-upload .upload-form { gap: 8px; }
    .page-upload #filePanel, .page-upload .drop-zone { min-height: 110px; }
    .page-upload .drop-zone { padding: 8px; }
}
