/* ─────────────────────────────────────────────────────────────
   전시회 QR 주문 — 디자인 토큰
   한국형 모바일 서비스 관례를 따른다. 흰 카드 / 연회색 캔버스 /
   포인트 컬러 1개 / 굵은 타이포 위계 / 큰 터치 타겟.
   ───────────────────────────────────────────────────────────── */
:root {
  color-scheme: light;

  --point: #3182f6;
  --point-strong: #1b64da;
  --point-weak: #eff5ff;
  --point-line: #c9dffd;

  --ink: #191f28;
  --ink-2: #4e5968;
  --ink-3: #8b95a1;
  --ink-4: #b0b8c1;

  --line: #e5e8eb;
  --line-soft: #f0f2f4;
  --fill: #f2f4f6;
  --canvas: #f7f8fa;
  --surface: #fff;

  --danger: #e02f42;
  --danger-weak: #fdeff1;
  --danger-line: #f6c9cf;
  --warn: #b45309;
  --warn-weak: #fff7e8;
  --warn-line: #f5dbaa;
  --ok: #00a05a;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-card: 0 1px 2px rgba(25, 31, 40, .04);
  --shadow-float: 0 -6px 20px rgba(25, 31, 40, .07);
}

* { box-sizing: border-box; }

html { background: var(--canvas); }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: -.01em;
  /* keep-all 은 한글을 어절 단위로 끊지만, 공백 없는 긴 상품명은 아예 못 쪼개
     min-content 폭이 뷰포트를 넘긴다. anywhere 를 함께 줘서 최후에는 강제로 끊는다. */
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

button, input, textarea { font: inherit; letter-spacing: inherit; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

:focus-visible { outline: 3px solid rgba(49, 130, 246, .35); outline-offset: 2px; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── 레이아웃 ─────────────────────────────────────────────── */
.app-shell {
  --nav-h: 0px;
  width: min(100%, 560px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 20px calc(32px + env(safe-area-inset-bottom));
  background: var(--canvas);
}

.app-shell.has-nav {
  --nav-h: 64px;
  padding-bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 12px;
  min-height: 56px;
  margin: 0 -20px 4px;
  padding: env(safe-area-inset-top) 20px 0;
  background: rgba(247, 248, 250, .88);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}

.brand { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; color: #fff; background: var(--point); border-radius: 9px; }
.brand-mark svg { width: 17px; height: 17px; }

.page { display: grid; gap: 14px; padding-top: 8px; }

.page-head { display: grid; gap: 6px; padding: 6px 2px 8px; }
.page-title { margin: 0; font-size: clamp(24px, 6.4vw, 30px); font-weight: 800; line-height: 1.34; letter-spacing: -.035em; }
.page-lead { margin: 0; color: var(--ink-3); font-size: 15px; line-height: 1.5; }

/* ── 카드·리스트 ──────────────────────────────────────────── */
.card {
  padding: 20px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.card.tight { padding: 16px; }

.stack { display: grid; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

.muted { color: var(--ink-3); }
.small { font-size: 14px; }
.strong { font-weight: 700; }
.no-margin { margin: 0; }
.center { text-align: center; }
.tnum { font-variant-numeric: tabular-nums; }

/* ── 배지·칩 ──────────────────────────────────────────────── */
.pending-badge, .status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.pending-badge { min-height: 34px; color: var(--warn); background: var(--warn-weak); border: 0; }
.status-chip { color: var(--point-strong); background: var(--point-weak); }

.pending-dot { width: 6px; height: 6px; background: #f59e0b; border-radius: 50%; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.8); } }

/* ── 입력 ─────────────────────────────────────────────────── */
.field { display: grid; gap: 8px; }
.field-label { color: var(--ink-2); font-size: 14px; font-weight: 700; }
.required { color: var(--point); }

.input, .textarea {
  width: 100%;
  min-height: 54px;
  padding: 15px 16px;
  color: var(--ink);
  background: var(--fill);
  border: 0;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  transition: background .12s ease, box-shadow .12s ease;
}

.input::placeholder, .textarea::placeholder { color: var(--ink-4); font-weight: 500; }
.input:focus, .textarea:focus { outline: 0; background: var(--surface); box-shadow: inset 0 0 0 2px var(--point); }
.textarea { min-height: 96px; line-height: 1.55; resize: vertical; }

/* ── 버튼 ─────────────────────────────────────────────────── */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 54px;
  padding: 14px 20px;
  color: #fff;
  background: var(--point);
  border: 0;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.02em;
  text-decoration: none;
  transition: background .12s ease, transform .06s ease, opacity .12s ease;
}

.button svg { flex: none; width: 18px; height: 18px; }
.button:active { transform: scale(.985); }
.button:hover { background: var(--point-strong); }
.button:disabled { cursor: not-allowed; opacity: .45; transform: none; }

.button.secondary { color: var(--ink-2); background: var(--fill); }
.button.secondary:hover { background: #e8ebee; }
.button.tonal { color: var(--point-strong); background: var(--point-weak); }
.button.tonal:hover { background: #e2edfe; }
.button.ghost { min-height: 40px; padding: 6px 10px; color: var(--ink-3); background: transparent; font-size: 15px; }
.button.ghost:hover { color: var(--ink-2); background: transparent; }
.button.danger { color: var(--danger); background: var(--danger-weak); }
.button.danger:hover { background: #fbe3e6; }
.button.compact { min-height: 42px; padding: 9px 14px; font-size: 15px; border-radius: 12px; }
.button.full { width: 100%; }

/* 하단 고정 CTA — 스크롤 중에도 항상 손 닿는 위치에 둔다. */
.cta-dock {
  position: sticky;
  bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom));
  z-index: 15;
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

/* ── 알림 ─────────────────────────────────────────────────── */
.notice {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  color: var(--point-strong);
  background: var(--point-weak);
  border-radius: var(--radius-md);
  font-size: 14.5px;
  line-height: 1.5;
}

.notice svg { flex: none; width: 18px; height: 18px; margin-top: 2px; }
.notice.warning { color: var(--warn); background: var(--warn-weak); }
.notice.error { color: var(--danger); background: var(--danger-weak); }
.notice.plain { color: var(--ink-3); background: var(--fill); }

/* ── 스캐너 ───────────────────────────────────────────────── */
.scanner-frame {
  position: relative;
  overflow: hidden;
  min-height: 300px;
  background: #14181f;
  border-radius: var(--radius-lg);
}

#qr-reader { min-height: 300px; color: #fff; background: #14181f; border: 0 !important; }
#qr-reader video { display: block; width: 100% !important; object-fit: cover; }
#qr-reader img, #qr-reader__dashboard_section_csr button { display: none !important; }
#qr-reader__scan_region { min-height: 300px; }
#qr-reader__dashboard_section_swaplink, #qr-reader__dashboard_section_csr span { color: #fff !important; }

.scan-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  pointer-events: none;
}
.scan-box { position: relative; flex: none; width: min(56%, 200px); aspect-ratio: 1; }
.scan-box b {
  position: absolute;
  width: 30px; height: 30px;
  border: 3px solid #fff;
  border-radius: 4px;
}
.scan-box b:nth-child(1) { top: 0; left: 0; border-width: 3px 0 0 3px; }
.scan-box b:nth-child(2) { top: 0; right: 0; border-width: 3px 3px 0 0; }
.scan-box b:nth-child(3) { bottom: 0; left: 0; border-width: 0 0 3px 3px; }
.scan-box b:nth-child(4) { bottom: 0; right: 0; border-width: 0 3px 3px 0; }
.scan-box i {
  position: absolute;
  left: 6%; right: 6%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #4c9bff, transparent);
  box-shadow: 0 0 12px rgba(76, 155, 255, .9);
  animation: sweep 2.4s ease-in-out infinite;
}
@keyframes sweep { 0%, 100% { top: 8%; } 50% { top: 90%; } }

.scan-hint {
  margin: 0;
  color: rgba(255, 255, 255, .82);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

.manual-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.manual-form .input { min-width: 0; }
.manual-form .input { text-transform: uppercase; }
.manual-form .button { min-width: 84px; padding-inline: 18px; }

/* ── 상품·수량 ────────────────────────────────────────────── */
.product-hero { display: grid; gap: 10px; }
.product-code {
  justify-self: start;
  padding: 4px 9px;
  color: var(--point-strong);
  background: var(--point-weak);
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: .04em;
}
.product-name { margin: 2px 0 0; font-size: 22px; font-weight: 700; line-height: 1.35; letter-spacing: -.03em; }
.product-price { font-size: 22px; font-weight: 800; letter-spacing: -.03em; }

.quantity-picker {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 4px;
  padding: 5px;
  background: var(--fill);
  border-radius: 999px;
}

.quantity-picker .button {
  min-height: 48px;
  padding: 0;
  color: var(--ink-2);
  background: var(--surface);
  border-radius: 50%;
  box-shadow: var(--shadow-card);
}
.quantity-picker .button:hover { background: #fff; color: var(--point); }
.quantity-picker .button svg { width: 18px; height: 18px; }

.quantity-input {
  min-width: 0;
  min-height: 48px;
  padding: 0;
  background: transparent;
  font-size: 20px;
  font-weight: 800;
  text-align: center;
  -moz-appearance: textfield;
}
.quantity-input:focus { background: transparent; box-shadow: none; }
.quantity-input::-webkit-outer-spin-button,
.quantity-input::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }

/* ── 장바구니 ─────────────────────────────────────────────── */
.cart-list { display: grid; gap: 10px; }

.cart-item {
  display: grid;
  gap: 14px;
  padding: 18px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

/* 금액이 길면(억 단위) 상품명 칸을 0까지 짜부라뜨리는 대신 아랫줄로 내려보낸다. */
.cart-meta { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 6px 12px; }
.cart-meta .grow { flex: 1 1 auto; min-width: 148px; }
.cart-name { margin: 4px 0 0; font-size: 17px; font-weight: 700; line-height: 1.4; letter-spacing: -.025em; }
.cart-line-total { font-size: 16px; font-weight: 800; white-space: nowrap; }
.cart-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.cart-controls .quantity-picker { grid-template-columns: 40px minmax(0, 1fr) 40px; max-width: 168px; }
.cart-controls .quantity-picker .button { min-height: 40px; }
.cart-controls .quantity-input { min-height: 40px; font-size: 17px; }

.summary { display: grid; gap: 12px; }
.summary-line { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; font-size: 15px; }
.summary-line > :last-child { white-space: nowrap; }
.summary-line strong { font-weight: 700; }
.summary-total {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  font-size: 16px;
  font-weight: 700;
}
.summary-total span:last-child { font-size: 22px; font-weight: 800; letter-spacing: -.03em; }

/* ── 빈 상태 ──────────────────────────────────────────────── */
.empty { display: grid; justify-items: center; gap: 6px; padding: 44px 20px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 60px; height: 60px; margin-bottom: 6px; color: var(--ink-4); background: var(--fill); border-radius: 50%; }
.empty-icon svg { width: 28px; height: 28px; }
.empty .button { margin-top: 12px; }

/* ── 완료 화면 ────────────────────────────────────────────── */
.confirmation { text-align: center; }
.confirmation .card { padding: 32px 20px; }

.success-mark {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin: 0 auto 4px;
  color: #fff;
  background: var(--point);
  border-radius: 50%;
  animation: pop .34s cubic-bezier(.2, .9, .3, 1.3);
}
.success-mark svg { width: 36px; height: 36px; }
.success-mark.is-warning { background: var(--danger); }
@keyframes pop { from { opacity: 0; transform: scale(.6); } }

.confirmation-number { margin: 2px 0 0; font-size: 34px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.confirmation .summary { margin-top: 20px; padding-top: 4px; text-align: left; }

/* ── 전송 대기 관리 ───────────────────────────────────────── */
.pending-list { display: grid; gap: 10px; }
.pending-entry { display: grid; gap: 12px; }
.pending-entry.is-blocked { box-shadow: inset 0 0 0 1px var(--danger-line); }
.status-chip.is-blocked { color: var(--danger); background: var(--danger-weak); }
.pending-reason { color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.pending-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.pending-actions .button { min-width: 0; padding-inline: 8px; font-size: 13px; }

/* ── 내 주문 ──────────────────────────────────────────────── */
.order-card { display: grid; gap: 12px; }
.order-number { font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.order-items { display: grid; gap: 9px; padding-top: 13px; border-top: 1px solid var(--line-soft); }
.order-item-line { display: flex; justify-content: space-between; gap: 12px; font-size: 14.5px; }
.order-item-line span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 하단 내비게이션 ──────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  z-index: 30;
  right: 0; bottom: 0; left: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: min(100%, 560px);
  margin: auto;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .94);
  border-top: 1px solid var(--line-soft);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}

.nav-button {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 2px;
  min-height: 52px;
  padding: 6px 4px;
  color: var(--ink-4);
  background: transparent;
  border: 0;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: -.01em;
  transition: color .12s ease;
}

.nav-button svg { width: 24px; height: 24px; }
.nav-button.active { color: var(--point); }

.nav-count {
  position: absolute;
  top: 2px;
  left: calc(50% + 6px);
  display: grid;
  place-items: center;
  min-width: 18px;
  min-height: 18px;
  padding: 1px 5px;
  color: #fff;
  background: var(--danger);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ── 로딩 ─────────────────────────────────────────────────── */
.spinner {
  width: 22px; height: 22px;
  border: 2.5px solid var(--line);
  border-top-color: var(--point);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 반응형 ───────────────────────────────────────────────── */
/* Fold 커버(280px)처럼 아주 좁은 화면에서는 수량칸이 사라진다. 세로로 쌓는다. */
@media (max-width: 330px) {
  .cart-controls { grid-template-columns: 1fr; }
  .cart-controls .quantity-picker { max-width: none; }
  .cart-controls .button.danger { justify-self: end; }
  .pending-actions { grid-template-columns: 1fr; }
}

/* 가로모드처럼 세로가 짧으면 스캐너가 하단 내비 뒤로 들어간다. 위아래를 줄인다. */
@media (orientation: landscape) and (max-height: 460px) {
  .page-head { gap: 2px; padding: 2px 2px 4px; }
  .page-title { font-size: 21px; }
  .page-lead { font-size: 13px; }
  .scanner-frame, #qr-reader, #qr-reader__scan_region { min-height: 190px; }
  .scan-overlay { gap: 10px; }
  .scan-box { width: min(34%, 130px); }
  .scan-hint { font-size: 12px; }
}

/* aspect-ratio 미지원 구형 엔진에서 .scan-box 높이가 0으로 붕괴하는 것 방지 */
@supports not (aspect-ratio: 1) {
  .scan-box { height: 200px; }
}

@media (min-width: 600px) {
  .app-shell { padding-inline: 24px; }
  .app-topbar { margin-inline: -24px; padding-inline: 24px; }
  .card { padding: 24px; }
}

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