html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Font */
@font-face {
    font-family: 'Pretendard-Regular';
    src: url('https://cdn.jsdelivr.net/gh/Project-Noonnu/noonfonts_2107@1.1/Pretendard-Regular.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

body {
    font-family: 'Pretendard-Regular', sans-serif;
    margin: 0;
    padding: 0;
    box-sizing: border-box;

    height: auto;              /* 핵심 */
    min-height: 100%;          /* html 기준 */
}

body.loading-lock {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100dvh;
    overflow: hidden;
}

/* Safari 키보드 대응 */
body.ios-keyboard-open {
    position: fixed;
    inset: 0;
    width: 100%;
    overflow: hidden;
}

/* 전체 페이지 */
.page {
    display: flex;
    flex-direction: column;
    min-height: var(--vvh, 100dvh);
    overflow: hidden;
}

.page-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;

    overflow-y: auto;
}

.loading {
    position: fixed; /* 화면 전체 고정 */
    z-index: 9999;
    inset: 0;
    width: 100%;

    height: 100dvh;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;

    display: flex;
    flex-direction: column;
    justify-content: flex-start; 
    align-items: center;     /* 좌우 중앙 */
    background-color: rgba(255, 255, 255, 1); /* 배경 불투명 */
    transition: opacity 0.3s ease;
}

.loading.d-none {
    opacity: 0;        /* 부드럽게 사라짐 */
    pointer-events: none;
}

/* Loading 텍스트 */
.loading h1 {
    font-size: 8vh;
    font-weight: 800;
    text-align: center;
}

.loading p {
    font-size: 4.5vh;
    font-weight: 600;
    text-align: center;
}

/* 페이지 상단 여백 */
.page-top {
    margin-top: 2vh;
    flex-shrink: 0;
}

.page-bottom-success {
    background-color: #f9f5ef;
    width: 100%;
}

.step-wrapper {
    display: flex;
    justify-content: space-between; /* item 간 간격 자동 균등 */
    width: 100%;                   /* 전체 화면 기준 */
    padding: 0 15vw;                 /* 양쪽 여백 → 원하는 값으로 조절 */
    box-sizing: border-box;         /* padding 포함 계산 */
    margin-bottom: 2vh;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 2vh;
}

.step-item .num {
    width: 5vh;
    height: 5vh;
    border-radius: 50%;
    border: 0.3vh solid #aaa;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5vh;
    font-size: 2.5vh;
}

.step-item.active {
    color: #F9BB23;
}

.step-item.active .num {
    border-color: #F9BB23;
    background-color: #F9BB23;
    color: #fff;
}

.page-success {
    justify-content: flex-start;
    background-image: url('/img/merz_mapping/mapping_main_bg.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
}

/* 타이틀 */
.page-success .title {
    margin-top: 5vh;
    font-size: 3rem;
    font-weight: 600;
    margin-bottom: 1vh;
    margin-left: 3vh;
}

.page-success .title2 {
    font-size: 3rem;
    font-weight: 600;
    margin-bottom: 1vh;
    margin-left: 3vh;
}

/* 결과 타이틀 */
.page-reg .title {
    margin-top: 5vh;
    position: absolute;
    bottom: 50%;
}

.page-unreg .title {
    margin-top: 5vh;
        position: absolute;
        bottom: 50%;
}

/* Loading 텍스트 */
.page-unreg h1 {
    font-size: 2.5vh;
    font-weight: 800;
    text-align: center;
}

.page-reg .title {
    margin-top: 5vh;
        position: absolute;
        bottom: 50%;
}

/* Loading 텍스트 */
.page-reg h1 {
    font-size: 2.5vh;
    font-weight: 800;
    text-align: center;
}


/* 체크 아이콘 */
.page-success .check-icon {
    width: 300px;  /* 이미지 기준으로 키움 */
    height: 300px;
    border-radius: 50%;
    background-color: #ff8c00;
    color: #fff;
    font-size: 9vh; /* 이미지 기준 키움 */
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 7vh;
    margin-bottom: 1vh; /* 버튼과 info-box 간격 줄임 */
}

/* 설명 텍스트 */
.page-success .desc {
    font-size: 2.5vh;
    margin-top: 2vh;
    margin-bottom: 2vh;
    color: #555555;
    text-align: center;
    line-height: 1.3;
}

/* 정보 박스 */
.page-success .info-box {
    margin-top: 5vh;
    width: 90%; /* 좌우 여백 이미지 기준 */
    box-sizing: border-box;
    padding: 1.5vh 2vw;
    font-size: 2vh;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fafafa;
    margin-bottom: 1vh; /* 버튼과의 간격 */
}

.page-success .info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.7vh;
    color: #222222;
}

.page-success .label {
    font-weight: 600;
}

.page-success .value {
    font-weight: 500;
    color: #333333;
}

.btn-trans-check {
    display: block;        /* 블록 요소로 만들기 */
    width: 100%;          /* 화면 전체 폭 */
    max-width: 90%;       /* 최대 폭 제한 제거 */
    box-sizing: border-box; /* 패딩 포함 폭 계산 */
    padding: 2rem 0;
    font-size: 2.5vh;
    font-weight: 400;
    background-image: url('/img/merz_mapping/auth_btn.png');
    background-position: center;
    background-size: cover;
    color: white;
    border-radius: 25px;
    border: none;
    cursor: pointer;
    margin: 0 auto 5vh;
    text-align: center;
    /*box-shadow: 0 2px 4px rgb(255 140 0 / 0.5);*/
}

/* hover는 이미지 유지 + 효과만 */
.btn-trans-check:hover:not(.disabled) {
    filter: brightness(1.05);
}

/* btn 비활성화 상태 */
.btn-trans-check.disabled {
    background: #cccccc;            /* 이미지 완전히 제거 */
    color: #666666;
    cursor: not-allowed;
    box-shadow: none;
}

/* 비활성화 hover 방지 */
.btn-trans-check.disabled:hover {
    filter: none;
}

/* Step 텍스트 크기 */
.step-item span {
    font-size: 2vh;
}

/* Step 숫자 크기 */
.step-item .num {
    font-size: 2.5vh;
}

/* 페이지 전체 여백 및 정렬 유지 */
.page-success .page-top {
    width: 100%;
    align-items: center;
}

/* 로고 */
.logo-merz {
    width: 100%;
    padding-top: 30%;
    background-image: url('/img/merz_mapping/merz_mapping_logo.png');
    background-repeat: no-repeat;
    background-position: center;
    margin-top: 10vh;
}

/* 로딩 로고 */
.logo-loading {
    position: absolute !important;
    width: 100%;
    padding-top: 100%;

    /* fallback (구형 브라우저) */
    background-image: url('/img/merz_mapping/merz_loading_logo_2.gif');

    /* WebP 지원 브라우저 */
    background-image: image-set(
        url('/img/merz_mapping/merz_loading_logo.webp') type('image/webp'),
        url('/img/merz_mapping/merz_loading_logo_2.gif') type('image/gif')
    );
    transform: translateY(-62px);
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
}

/* 큰 텍스트 */
.text-wrapper-merz {
    text-align: center;
    margin-top: auto;
    margin-bottom: 13vh;
}

.text-wrapper-merz h1 {
    font-weight: 800;
    color: black;
    line-height: 1.3;
    font-size: 3.5rem;
}

/* 작은 안내 텍스트 */
.info-wrapper-merz {
    width: calc(100% - 40px);
    margin: 0 20px;
    text-align: center;
    bottom: 13vh;
}

.info-wrapper-merz h1 {
    font-size: 3.5rem;
    line-height: 1.3;
    text-align: center;
}

.info-wrapper-merz h2 {
    margin-top: 1vh;      /* 중앙 정렬 방해하는 margin 제거 */
    font-size: 1.5rem;
    line-height: 1.5;
    color: #6A6A6A;
    text-align: center;
}

/* qr 안내 텍스트 */
.qr-info-wrapper-merz {
    margin-left: 3vh;
    text-align: left;
    margin-bottom: 5vh;
}

.qr-info-wrapper-merz h1 {
    font-size: 2.7rem;
    line-height: 1.5;
    text-align: left;
    font-weight: 100 !important;
}

/* 숨김 */
.hidden {
    display: none !important;
}

/* ======================
   스캐너 팝업
   ====================== */
.scanner-root {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
     z-index: 20000 !important;
}

.scanner-popup {
    background: #000;
    border-radius: 0;        /* 전체 화면이므로 제거 */
    overflow: hidden;
    width: 100%;
    height: 100%;
}

.scanner-wrapper {
    position: relative;
    width: 100%;
    height: 100%;        /* 전체 화면 */
    overflow: hidden;
    background: #000;
}

.qr-camera-wrapper {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.camera-stage {
    position: absolute;
    inset: 0;

    display: flex;
    justify-content: center;
    align-items: center;

    overflow: hidden;
}

/* 비디오 : 부모 박스를 완전히 채우고 object-fit으로 잘라서 보여줌 -> 검은 줄 제거 */
#qr-video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background-color: black;
}

/* 마스크(정사각형 인식 영역) */
.scanner-overlay {
    position: absolute;
    inset: 0;
}

.mask {
    position: absolute;
    background: rgba(0, 0, 0, 0.55);
}

/* 마스크/프레임(종전과 동일하되 scan-frame 크기 일치) */
.scan-frame {
    position: absolute;
    width: 66vw;
    height: 66vw;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    box-sizing: border-box;

    /* 둥근 테두리 */
    border-radius: 24px;

    /* 굵은 테두리 */
    border: 12px solid #EAB449;;

    /* 내부 살짝 밝게 (투명 면) */
    background: rgba(255, 255, 255, 0.05);

    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);

    z-index: 10;
}

/* 마스크 재계산 (scan-frame = 44vw 기준) */
.mask-top {
    top: 0;
    left: 0;
    width: 100%;
    height: calc(50% - 33vw);
}
.mask-bottom {
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(50% - 33vw);
}
.mask-left {
    top: calc(50% - 33vw);
    bottom: calc(50% - 33vw);
    left: 0;
    width: calc(50% - 33vw);
}
.mask-right {
    top: calc(50% - 33vw);
    bottom: calc(50% - 33vw);
    right: 0;
    width: calc(50% - 33vw);
}

/* 마스크는 클릭 이벤트 무시 */
.scanner-overlay .mask {
    pointer-events: none;
}

/* 프레임 라인 (하얀 모서리)
.corner {
    width: 22px;
    height: 22px;
    border: 3px solid #fff;
    position: absolute;
    box-sizing: border-box;
}

.corner.tl { top: 0; left: 0; border-right: none; border-bottom: none; }
.corner.tr { top: 0; right: 0; border-left: none; border-bottom: none; }
.corner.bl { bottom: 0; left: 0; border-right: none; border-top: none; }
.corner.br { bottom: 0; right: 0; border-left: none; border-top: none; }*/

.hint {
    position: absolute;
    bottom: calc(50% + (min(66vw, 66vh) / 2) + 20px);   /* 인식 표시 윗부분*/
    left: 50%;
    transform: translateX(-50%);
    width: 100%;          /* 카메라 가로 길이에 맞춤 */
    max-width: 100%;      /* 넘침 방지 */
    padding: 30px 16px;
    color: #FCB53B;
    font-size: 35px;
    text-align: center;
    white-space: pre-line;
    z-index: 15;  /* overlay 위로 */
}

 /*  관리자 로그인 버튼 */
.loading .btn-login {
    position: absolute;
    bottom: 100px;   /* 원하는 만큼 조정 */
    right: 100px;    /* 원하는 만큼 조정 */
    padding: 6px 12px;
    font-size: 2rem;
    background-color: #F9BB23;
    color: white;
    opacity: 0.8;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    text-align: center;
}

/* loading 전체 영역 */
.page .loading {
    min-height: unset;
    width: 100%;
    background-image: url("/static/img/merz_mapping/merz_default_bg.png"); /* 기본 배경*/
    overflow: hidden;
    background-position: center;
    background-size: cover;
}

/* .page-reg 전체 영역 */
.page .page-reg {
    min-height: 100vh;
    width: 100%;
    background-image: url("/static/img/merz_mapping/merz_default_bg.png"); /* 기본 배경*/
    overflow: hidden;
    background-position: center;
    background-size: cover;
}

/* page-unreg 전체 영역 */
.page .page-unreg {
    min-height: 100vh;
    width: 100%;
    background-image: url("/static/img/merz_mapping/merz_default_bg.png"); /* 기본 배경*/
    overflow: hidden;
    background-position: center;
    background-size: cover;
}


/* 배경 이미지 */
.bg-mapping {
    position: absolute;
    inset: 0;
    background-image: url("/static/img/merz_mapping/bg_mapping.png");
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover; /* 비율 유지 */
}

/* 로딩 UI는 위로 */
.loading > *:not(.bg-mapping) {
    position: relative;
    z-index: 1;
}

/* 관리자 로그인 링크 */

/* 홈페이지 이동 링크 텍스트 */
.loading .mapping-login {
    display: block;
    position: absolute;
    bottom: calc(120px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);

    font-size: 2.1vh;
    color: #888888;
    text-align: center;
    text-decoration: underline;
    cursor: pointer;
    margin-bottom: 1vh
}

.mapping-login:hover {
    color: #555555;
    text-decoration: none;
}

/* 관리자 로그인 시 배경 이미지 제거 */
.bg-mapping.off {
    display: none !important;
}

/* 관리자 패널 */
.admin-panel {
    position: absolute !important;
    left: 0;
    right: 0;

    padding: 0 48px;
    text-align: center;

    background: none;      /* 배경 제거 */
    border-radius: 0;
    z-index: 6;
}

.admin-panel h2 {
    color: black;
    font-weight: 600;
    margin-bottom: 3vh;

    font-size: 4rem !important;   /* 강제 */
    line-height: 1.3;
}

.admin-panel {
    position: fixed;
    z-index: 2000;
    flex-direction: column;
    justify-content: space-between;
}

/* 상단 영역 */
.admin-login-wrapper {
    padding: 48px 24px 24px;
    text-align: center;
}

.admin-logo .logo-merz {
    margin: 0 auto 8px;
}

/* 입력창 */
.admin-input-group {
    display: flex;
    flex-direction: column;
    gap: 1vh;
    margin-bottom: 2vh;
}

.admin-input {
    height: 100%;
    border-radius: 4px;
    border: none;
    padding: 1.5vh 1vh;
    font-size: 2vh;
    background: #fff;
    text-align: left;
}

/* 로그인 버튼 */
.admin-login-btn {
display: block;        /* 블록 요소로 만들기 */
    width: 100%;          /* 화면 전체 폭 */
    box-sizing: border-box; /* 패딩 포함 폭 계산 */
    padding: 1.5rem 0;
    font-size: 2.5vh;
    font-weight: 400;
    border-radius: 25px;
    color: white;
    border: none;
    background-image: url('/img/merz_mapping/auth_btn.png');
    background-position: center;
    background-size: cover;
    text-align: center;
}

/* 관리자 로그인 placeholder 색상 */
.admin-input::placeholder {
    color: #666666;
    opacity: 1; /* iOS Safari에서 흐려지는 것 방지 */
}

/* 호환성 (구형 브라우저 대비) */
.admin-input::-webkit-input-placeholder {
    color: #666666;
}
.admin-input:-ms-input-placeholder {
    color: #666666;
}

/* 관리자 로그인 에러 메시지 */
.admin-login-error {
    margin-top: 0.5vh;
    font-size: 1.5vh !important;
    color: #d32f2f; /* 붉은색 */
}

/* 숨김 처리 */
.hidden {
    display: none !important;
}

.hint2 {
    position: absolute;
    bottom: calc(50% - (min(66vw, 66vh) / 2) - 110px);   /* 인식 표시 아래*/
    left: 50%;
    transform: translateX(-50%);
    width: 100%;          /* 카메라 가로 길이에 맞춤 */
    max-width: 100%;      /* 넘침 방지 */
    padding: 30px 16px;
    color: #FFF;
    font-size: 35px;
    text-align: center;
    white-space: pre-line;
    z-index: 15;  /* overlay 위로 */
}

.btn-typing {
    position: absolute;
    bottom: calc(50% - (min(66vw, 66vh) / 2) - 180px);   /* 인식 표시 아래*/
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 40px;
    font-size: 35px;
    background-image: url('/img/typing_btn_bg.png');
    background-position: center;
    background-size: cover;
    color: white;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    text-align: center;
    z-index: 15;
}

/* ===== underline input ===== */

.underline-input-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 20px;
}

.underline-input-row .label {
    font-size: 14px;
    color: #555;
}

/* input + icon + underline 컨테이너 */
.underline-input-wrapper {
    display: flex;
    align-items: center;
    border-bottom: 4px solid gray;
    padding: 0 4px;               /* 좌우만 최소 */
    margin-right: 2vh;
    margin-bottom: 4vh
}

/* input */
.underline-input {
    flex: 1 1 auto;          /* 남은 영역만 차지 */
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font-size: 2.5rem;
    padding: 1vh 0vh;
    line-height: 1.2;
    box-sizing: border-box;
}

/* placeholder */
.underline-input::placeholder {
    color: #aaa;
}

/* hover */
.icon-btn:hover {
    color: #000;
}

/* readonly 스타일 */
.underline-input-wrapper.readonly {
    border-bottom-color: #bbb;
}

.underline-input-wrapper.readonly .underline-input {
    color: #777;
}

/* ===== Toast Message ===== */
.toast {
    position: fixed;
    left: 50%;
    bottom: 14%;
    transform: translateX(-50%);

    width: 80%;
    padding: 2rem 24px;

    background: gray;
    color: #fff;
    font-size: 2.2vh;
    font-weight: 500;
    text-align: center;

    border-radius: 30px;
    z-index: 30000;

    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* 표시 상태 */
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-10px);
}

.toast-inner {
    display: flex;
    align-items: center;
    gap: 1.5vh;
    margin-left: 1vh;
}

/* 원형 */
.check-icon {
    width: 3vh;
    height: 3vh;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 1.5vh;
    font-weight: bold;
    color: gray;
    line-height: 1;

    user-select: none;
}

/* 성공 */
.check-icon.success {
    background-color: #28a745; /* 초록 */
}

/* 실패 */
.check-icon.error {
    background-color: #dc3545; /* 빨강 */
}

.btn-rescan {
    position: relative;
    background-color: white;
    color: gray;
    border-radius: 25px;
    border: none;
    border-style: solid;
    text-align: center;
}

/* 시리얼 입력 + QR 버튼 한 줄 */
.serial-row {
    width: 100%;
    max-width: 90%;      /* 저장 버튼과 동일 */
    margin: 0 auto;

    display: flex;
    align-items: flex-end;
    gap: 12px;

    overflow: hidden;   /* 마지막 안전장치 */
}

/* 입력창 영역은 최대한 넓게 */
.serial-row .underline-input-wrapper {
    flex: 1 1 0%;
    min-width: 0;
}

.serial-row .btn-rescan {
    flex: 0 1 auto;
    min-width: 0;

    margin-left: auto;   /* 오른쪽 정렬 */

    max-width: 35%;
    white-space: nowrap;

    padding: clamp(14px, 2vw, 22px)
             clamp(28px, 4vw, 48px);

    font-size: 2.3rem;
    font-weight: 600;

    align-self: flex-end;
    margin-bottom: 4vh;
}

.btn-recheck {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);

    bottom: calc(3vh + env(safe-area-inset-bottom));

    width: 90%;
    max-width: 90%;

    font-size: 2vh;

    /* 높이는 살짝 여유만 */
    padding: 1.5vh 0;

    background-image: url('/img/merz_mapping/auth_btn.png');
    background-position: center;
    background-size: cover;

    color: white;
    border-radius: 15px;
    border: none;
    cursor: pointer;

    margin: 0;
}

.inner-serial-photo-wrapper {
	display: flex;
	align-items: center;
	gap: 12px;
	margin: 0 3vh 3vh;
}

/* 카메라 버튼 */
.camera-box {
	width: 6vh;
	height: 6vh;
	border: 1.5px solid #d9d9d9;
	border-radius: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #f5f5f5;
	cursor: pointer;
}

.camera-box i {
	font-size: 2.5vh;
	color: #666;
}

/* 미리보기 */
.photo-preview {
	position: relative;
	width: 6vh;
	height: 6vh;
}

.photo-preview img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 10px;
	border: 1px solid #d9d9d9;
}

/* 삭제 버튼 */
.photo-remove {
	position: absolute;
	top: -6px;
	right: -6px;
	width: 1.5vh;
	height: 1.5vh;
	border-radius: 50%;
	border: none;
	background: #000;
	color: #fff;
	font-size: 1vh;
	line-height: 18px;
	cursor: pointer;
}

.page-error h1 {
    font-size: 3vh;   /* 원하는 크기 */
}

.page-error p {
    font-size: 2vh;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}