/* 티켓조회 b2 · 회원 화면과 스태프 스캐너 공용 */
:root {
    --bg: #f3f6f9;
    --surface: #ffffff;
    --line: #e2e8ef;
    --text: #17212b;
    --muted: #5d6b79;
    --faint: #8a97a4;
    --accent: #2f7fb5;          /* 코믹월드 파랑 (흰 글씨 대비 확보한 진한 쪽) */
    --accent-soft: #e6f3fb;
    --on-accent: #ffffff;
    --ok: #15803d;
    --ok-soft: #e7f6ec;
    --warn: #b45309;
    --warn-soft: #fdf3e3;
    --bad: #c62828;
    --bad-soft: #fdecec;
    /*
     * 색 역할
     * accent 파랑  : 행사 브랜드 · 처리 버튼 (발권하기, 수령 처리, 보관 시작)
     * text 진한 회색: 다음 스캔 · 전체 데스크 (처리와 상관없는 이동)
     * ok 초록      : 끝난 일 (발권 완료, 수령 완료)
     * warn 주황    : 확인이 필요함 (오늘 티켓 없음, 처리할 항목 없음)
     * bad 빨강     : 막힘 (다른 데스크 QR, 권한 없음)
     * head 보라    : 우선입장 대상자 (줄을 따로 서야 해서 한눈에 구분)
     * carrier 청록 · bag 갈색: 물품보관 번호표 (선반 구역이 달라서 종류별로 다른 색)
     */
    --head: #6d28d9;
    --head-soft: #f1eafe;
    --carrier: #0f766e;
    --carrier-soft: #e6f6f4;
    --bag: #9a3412;
    --bag-soft: #fdf0e7;
    --radius: 14px;
    --radius-sm: 10px;
    --tap: 48px;
}
.is-moongu {
    --accent: #8a6a00;
    --accent-soft: #fff6cf;
    --on-accent: #ffffff;
}
.is-moongu .qr-card__head,
.is-moongu .btn--primary { background: #ffd43b; color: #3b3000; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 'Noto Sans KR', system-ui, -apple-system, 'Malgun Gothic', sans-serif;
    word-break: keep-all;
}
a { color: var(--accent); }
button, input { font: inherit; }
:focus-visible { outline: 3px solid #1d6fd8; outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------------ 상단 */
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 8px;
    height: 56px; padding: 0 8px 0 16px;
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: saturate(1.4) blur(6px);
}
.topbar__title { flex: 1; min-width: 0; margin: 0; font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__sub { color: var(--muted); font-weight: 400; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: var(--tap); height: var(--tap); padding: 0;
    border: 0; border-radius: 50%; background: transparent; color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: #eef2f6; }
.icon-btn svg { width: 24px; height: 24px; }

.page { max-width: 480px; margin: 0 auto; padding: 16px 16px 40px; }

/* ------------------------------------------------------------------ 공통 블록 */
.section { margin-top: 24px; }
.section__title { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 8px; font-size: 15px; font-weight: 700; }
.section__title small { color: var(--muted); font-size: 13px; font-weight: 400; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 12px 16px; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.list__main { flex: 1; min-width: 0; }
.list__name { display: block; font-weight: 700; }
.list__meta { display: block; color: var(--muted); font-size: 13px; }
.empty { margin: 0; padding: 20px 16px; color: var(--muted); font-size: 14px; text-align: center; }
.empty__title { display: block; margin-bottom: 6px; color: var(--text); font-size: 16px; }
.empty__key { color: var(--bad); }
.empty__act { padding: 0 16px 16px; text-align: center; }
.note { margin: 8px 0 0; color: var(--muted); font-size: 13px; }

.chip {
    display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
    padding: 3px 10px; border-radius: 999px;
    font-size: 13px; font-weight: 700; white-space: nowrap;
    background: #eef2f6; color: var(--muted);
}
.chip--ok { background: var(--ok-soft); color: var(--ok); }
.chip--wait { background: var(--warn-soft); color: var(--warn); }
.chip--accent { background: var(--accent-soft); color: var(--accent); }
.chip svg { width: 14px; height: 14px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: var(--tap); padding: 0 18px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text);
    font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn--primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.btn--ok { background: var(--ok); border-color: transparent; color: #fff; }
.btn--block { width: 100%; }
.btn--sm { min-height: 40px; padding: 0 14px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 처리 중 (메일 발송 등) */
.is-loading, .btn.is-loading:disabled { opacity: .85; cursor: progress; }
.is-loading::before {
    content: ''; display: inline-block; flex-shrink: 0;
    width: 16px; height: 16px; margin-right: 8px; vertical-align: -3px;
    border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
    animation: b2-spin .7s linear infinite;
}
@keyframes b2-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .is-loading::before { animation-duration: 2s; } }
.btn-text { padding: 10px 4px; border: 0; background: none; color: var(--accent); font-weight: 700; cursor: pointer; }

.banner { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; }
.banner--staff { background: #17212b; color: #fff; }
.banner--staff a { margin-left: auto; color: #fff; font-weight: 700; white-space: nowrap; }
.banner--test { background: var(--warn-soft); color: #7a3e04; }
.banner--test a { margin-left: auto; color: #7a3e04; font-weight: 700; white-space: nowrap; }

/* ------------------------------------------------------------------ 로그인 */
.hero h1 { margin: 8px 0 4px; font-size: 22px; line-height: 1.35; }
.hero p { margin: 0 0 20px; color: var(--muted); }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 700; }
.field input {
    width: 100%; height: 50px; padding: 0 14px;
    border: 1px solid #c6d1dc; border-radius: var(--radius-sm); background: #fff; color: var(--text);
}
.field input:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
.form-panel { padding: 20px 16px; }
.links { display: flex; justify-content: center; gap: 16px; margin-top: 8px; }
.recover { margin-top: 12px; padding: 16px; }
.recover h2 { margin: 0 0 12px; font-size: 16px; }
.notice-item { padding: 14px 16px; border-top: 1px solid var(--line); }
.notice-item:first-child { border-top: 0; }
.notice-item h3 { margin: 0 0 4px; font-size: 14px; }
.notice-item p { margin: 0; color: var(--muted); font-size: 14px; white-space: pre-wrap; }
.notice-item strong { color: var(--bad); }

/* ------------------------------------------------------------------ 회원 · QR */
.who { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 12px; }
.who h1 { margin: 0; font-size: 20px; }
.qr-card { overflow: hidden; }
.qr-card__head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 12px 16px; background: var(--accent); color: var(--on-accent);
    font-weight: 700;
}
.qr-card__head .chip--head { margin-left: 6px; background: var(--head); color: #fff; font-weight: 800; box-shadow: 0 0 0 2px #fff; }
.qr-card__head .chip--ok { background: #fff; color: var(--accent); }
.qr-card__body { padding: 20px 16px 16px; text-align: center; }
.qr-box { position: relative; width: 232px; height: 232px; margin: 0 auto; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.qr-box canvas, .qr-box img { display: block; width: 100% !important; height: auto !important; image-rendering: pixelated; }
.qr-box__veil {
    position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    padding: 16px; border-radius: 12px; background: rgba(255, 255, 255, .95); color: var(--text); font-size: 14px; font-weight: 700;
}
.qr-box.is-stale .qr-box__veil { display: flex; }
.qr-id { margin: 12px 0 2px; font-size: 14px; color: var(--muted); }
.qr-help { margin: 0; font-size: 15px; font-weight: 700; }
.qr-timer { margin: 14px auto 0; max-width: 232px; }
.qr-timer__bar { height: 4px; border-radius: 2px; background: #e8edf2; overflow: hidden; }
.qr-timer__bar i { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; }
.qr-timer__text { margin-top: 6px; color: var(--faint); font-size: 12px; }
.qr-closed { padding: 28px 16px; text-align: center; }
.qr-closed svg { width: 44px; height: 44px; color: var(--faint); }
.qr-closed p { margin: 8px 0 0; color: var(--muted); word-break: keep-all; }
@media (max-width: 559px) {
    .qr-closed p { font-size: 14px; line-height: 1.55; }
}
.qr-closed strong { display: block; color: var(--text); font-size: 16px; }
.qr-done svg { color: var(--ok); }
.qr-done strong { color: var(--ok); }
.btn-key, .qr-closed .btn-key { display: inline; font-size: inherit; color: var(--accent); font-weight: 700; }
.qr-closed .empty__key { display: inline; font-size: inherit; color: var(--bad); }

.ticket { position: relative; padding-left: 20px !important; }
.ticket::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 5px; border-radius: 0 4px 4px 0; background: var(--ticket-color, var(--accent)); }
.ticket__cnt { font-size: 17px; font-weight: 700; white-space: nowrap; }

/* ------------------------------------------------------------------ 티켓 모양 카드 */
.tix-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.tix-list--owned { padding: 12px; gap: 8px; background: var(--bg); }
.tix-wrap { filter: drop-shadow(0 1px 1px rgba(23, 33, 43, .08)) drop-shadow(0 4px 10px rgba(23, 33, 43, .06)); }
.tix {
    --stub: 84px;
    --notch: 9px;
    position: relative;
    display: flex;
    min-height: 92px;
    background: var(--surface);
    border-radius: 12px;
    /* 절취선 위아래 반원 홈 */
    -webkit-mask:
        radial-gradient(circle at calc(100% - var(--stub)) 0, transparent var(--notch), #000 calc(var(--notch) + .5px)) top / 100% 51% no-repeat,
        radial-gradient(circle at calc(100% - var(--stub)) 100%, transparent var(--notch), #000 calc(var(--notch) + .5px)) bottom / 100% 51% no-repeat;
    mask:
        radial-gradient(circle at calc(100% - var(--stub)) 0, transparent var(--notch), #000 calc(var(--notch) + .5px)) top / 100% 51% no-repeat,
        radial-gradient(circle at calc(100% - var(--stub)) 100%, transparent var(--notch), #000 calc(var(--notch) + .5px)) bottom / 100% 51% no-repeat;
}
.tix::before { /* 왼쪽 색 띠: 요일 · 종류별 색 */
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 8px;
    border-radius: 12px 0 0 12px; background: var(--ticket-color, var(--accent));
}
.tix__main { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 14px 14px 14px 22px; }
.tix__kicker { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.tix__name { font-size: 16px; line-height: 1.35; overflow-wrap: anywhere; }
.tix__meta { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.tix__stub {
    position: relative;
    flex: 0 0 var(--stub);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border-left: 2px dashed var(--line);
    text-align: center;
}
.tix__qty { display: flex; align-items: baseline; gap: 2px; white-space: nowrap; }
.tix__cnt { font-size: 28px; font-weight: 700; line-height: 1; color: var(--text); }
.tix__unit { color: var(--muted); font-size: 14px; font-weight: 700; }
.tix__stamp {
    margin-top: 6px; padding: 2px 6px;
    border: 2px solid var(--ok); border-radius: 4px;
    color: var(--ok); font-size: 11px; font-weight: 700; white-space: nowrap;
    transform: rotate(-8deg);
}
.tix.is-used .tix__cnt { color: var(--muted); }

.tix--sm { --stub: 68px; --notch: 7px; min-height: 68px; }
.tix--sm::before { width: 6px; background: #c6d1dc; }
.tix--sm .tix__main { padding: 10px 12px 10px 18px; }
.tix--sm .tix__name { font-size: 14px; }
.tix--sm .tix__cnt { font-size: 20px; }
.tix--sm .tix__unit { font-size: 12px; }

.head-notice { margin: 0 16px 14px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); font-size: 14px; white-space: pre-wrap; }
.locker-nos { font-weight: 700; color: var(--text); }

details.panel > summary { display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 0 16px; font-weight: 700; cursor: pointer; list-style: none; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after { content: ''; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin-top: -4px; }
details.panel[open] > summary::after { transform: rotate(-135deg); margin-top: 4px; }
details.panel[open] > summary { border-bottom: 1px solid var(--line); }

.foot { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 28px; }

@media (min-width: 768px) {
    .page { padding-top: 28px; }
    .qr-box { width: 260px; height: 260px; }
}

/* ---------------------------------------------------------- 수령 QR 창 */
.qr-help__sub { display: inline-block; margin-top: 4px; color: var(--muted); font-size: 13px; font-weight: 400; }
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(14, 21, 28, .55); }
.sheet__panel {
    position: relative; width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-radius: 20px 20px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, .2);
    animation: b2-sheet-up .2s ease-out;
}
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 8px 4px 20px; }
.sheet__head h2 { margin: 0; font-size: 18px; }
.sheet__body { padding: 8px 16px 24px; text-align: center; }
.sheet__body .qr-help { margin-top: 14px; }
body.is-sheet-open { overflow: hidden; }
@keyframes b2-sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 560px) {
    .sheet { align-items: center; }
    .sheet__panel { border-radius: 20px; }
}

/* 처리 완료 알림 */
.flash {
    position: fixed; left: 50%; top: 16px; z-index: 60; transform: translateX(-50%);
    max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px;
    background: var(--ok); color: #fff; font-weight: 700; box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
    transition: opacity .5s, transform .5s;
}
.flash.is-out { opacity: 0; transform: translate(-50%, -8px); }
@media (prefers-reduced-motion: reduce) {
    .sheet__panel { animation: none; }
    .flash { transition: none; }
}
.list > li > .btn { flex-shrink: 0; }

/* 구매한 티켓 전체: 행사일이 아닐 때 강조 */
.owned__title { display: flex; flex-direction: column; gap: 2px; }
.owned__title small { font-size: 13px; font-weight: 400; color: var(--muted); }
.owned__count { margin-left: auto; margin-right: 12px; }
.owned--focus { border-color: var(--accent); overflow: hidden; box-shadow: 0 4px 14px rgba(47, 127, 181, .14); }
.owned--focus > summary { min-height: 64px; padding-block: 10px; background: var(--accent); color: var(--on-accent); }
.owned--focus > summary .owned__title small { color: inherit; opacity: .85; }
.owned--focus > summary .owned__count { background: rgba(255, 255, 255, .22); color: inherit; }
.owned--focus > summary::after { border-color: currentColor; }
.owned--focus[open] > summary { border-bottom-color: transparent; }
.owned--focus .tix--sm::before { background: var(--accent); }
.is-moongu .owned--focus > summary { background: #ffd43b; color: #3b3000; }
.is-moongu .owned--focus { border-color: #e0b400; }

/* 임시: 직접 처리 버튼 (B2_SELF_BTN). QR 보조라 채우지 않고 강조색 테두리로 보이게 */
.self-row { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 14px 0 0; color: var(--muted); font-size: 13px; font-weight: 700; }
.self-row--panel { justify-content: flex-start; margin: -4px 16px 14px; }
.act-pair { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }
.btn-self {
    min-height: 38px; padding: 0 14px;
    border: 2px solid var(--accent); border-radius: var(--radius-sm);
    background: var(--accent-soft); color: var(--accent);
    font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
}
.btn-self:active { background: var(--accent); color: var(--on-accent); }
.btn-self:disabled { opacity: .6; cursor: progress; }
.btn-self.is-loading::before { width: 12px; height: 12px; margin-right: 4px; }
.self-li { justify-content: space-between; min-height: 0 !important; padding-top: 0 !important; border-top: 0 !important; }
.self-li__label { color: var(--muted); font-size: 13px; font-weight: 700; }
.self-locker { display: grid !important; gap: 10px; padding: 4px 16px 16px !important; border-top: 0 !important; }
.self-locker[hidden] { display: none !important; }
.self-locker__note { margin: 0; color: var(--muted); font-size: 13px; }
.self-locker__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 700; }
.self-stepper { display: flex; align-items: center; gap: 8px; }
.self-stepper button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--text); font-size: 20px; font-weight: 700; cursor: pointer; }
.self-stepper output { min-width: 22px; text-align: center; font-weight: 700; }
.btn-self--block { width: 100%; }

/* 물품보관 번호표 (스태프 스캐너 scan.css 와 같은 모양) */
.list > li.locker-tags-li { display: block; min-height: 0; padding-top: 0; border-top: 0; }
.locker-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.locker-tag {
    display: inline-flex; flex-direction: column; align-items: center; min-width: 76px; padding: 6px 12px 8px;
    border: 2px solid var(--carrier); border-radius: 10px; background: var(--carrier-soft); color: var(--carrier);
    font-size: 28px; font-weight: 800; line-height: 1.1; letter-spacing: .5px;
}
.locker-tag small { font-size: 12px; font-weight: 700; letter-spacing: 0; color: inherit; opacity: .8; }
.locker-tag--bag { border-color: var(--bag); background: var(--bag-soft); color: var(--bag); }

/* 입장 QR 아래 [직접 발권]: QR 이 우선이라 더 작게 */
.qr-view .self-row { margin-top: 10px; font-size: 12px; }
.qr-view .self-row .btn-self { min-height: 30px; padding: 0 10px; border-width: 1px; border-radius: 4px; font-size: 12px; }

/* 현장 서비스의 직접 처리 버튼: 평소엔 숨김, "QR 인식이 안 되나요?" 를 눌렀을 때만 보임 */
.svc:not(.is-self-open) .btn-self,
.svc:not(.is-self-open) .self-li,
.svc:not(.is-self-open) .self-locker { display: none !important; }
.self-reveal { margin: 8px 0 0; text-align: right; }
.self-reveal__btn { padding: 6px 2px; border: 0; background: none; color: var(--faint); font: inherit; font-size: 12px; text-decoration: underline; cursor: pointer; }

/* 수량 +/- 를 빠르게 연달아 눌러도 화면이 확대되거나 글자가 선택되지 않게 */
.self-stepper, .self-stepper button, .self-stepper output, .btn-self { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
