:root {
  --bg: #f2f4f6;
  --text: #191f28;
  --sub: #6b7684;
  --faint: #8b95a1;
  --line: #f2f4f6;
  --field: #f2f4f6;
  --red: #e5323c;
  --blue: #3182f6;
  --blue-soft: #e8f3ff;
  color-scheme: light;
}
* { box-sizing: border-box; }
/* 버튼을 빠르게 두 번 눌러도 화면이 확대되지 않게 */
html { touch-action: manipulation; }
button, label, summary { -webkit-tap-highlight-color: transparent; }
p { margin: 0; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff;
  padding: calc(14px + env(safe-area-inset-top)) 0 0;
}
header > * { max-width: 640px; margin-left: auto; margin-right: auto; padding-left: 16px; padding-right: 16px; }
h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.03em; }
.titlebar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
#tipsBtn {
  flex: none;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 99px;
  background: var(--blue-soft);
  color: var(--blue);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
#tipsBtn:active { transform: scale(0.96); }

.search { position: relative; display: flex; }
.search .glass {
  position: absolute;
  left: 30px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--faint);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}
.search input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 14px 0 40px;
  border: 0;
  border-radius: 12px;
  background: var(--field);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  outline: none;
}
.search input::placeholder { color: var(--faint); }
.search input:focus { box-shadow: inset 0 0 0 2px var(--blue); background: #fff; }

#cats {
  display: flex;
  gap: 20px;
  margin-top: 6px;
  /* 좌우로만 움직이게: 세로 스크롤과 끝에서 튕기는 동작을 막는다 */
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  border-bottom: 1px solid #e5e8eb;
}
#cats::-webkit-scrollbar { display: none; }
#cats button {
  flex: none;
  padding: 10px 0 12px;
  border: 0;
  background: none;
  color: var(--faint);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
/* 밑줄을 테두리 대신 안쪽 그림자로 그려서 탭 줄 밖으로 삐져나오지 않게 한다 */
#cats button.on { color: var(--text); box-shadow: inset 0 -2px 0 var(--text); }

main { max-width: 640px; margin: 0 auto; padding: 0 12px; }
.caption { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 2px 8px 6px; font-size: 13px; color: var(--sub); }
#sort {
  appearance: none;
  -webkit-appearance: none;
  height: 32px;
  padding: 0 26px 0 10px;
  border: 0;
  border-radius: 8px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%236b7684' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 8px center / 12px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* 구매처·반입금지 필터 */
.filters { display: flex; gap: 8px; padding: 0 2px 10px; }
#store {
  appearance: none;
  -webkit-appearance: none;
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 28px 0 12px;
  border: 0;
  border-radius: 10px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%236b7684' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center / 12px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
#hideBan {
  flex: none;
  height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: #fff;
  color: var(--sub);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
#hideBan.on { background: var(--text); color: #fff; }

#list { list-style: none; margin: 0; padding: 0; background: #fff; border-radius: 16px; overflow: hidden; }
.row + .row .head { border-top: 1px solid var(--line); }
.head { display: flex; align-items: center; gap: 14px; padding: 14px 12px 14px 16px; cursor: pointer; }
.head:active { background: #f9fafb; }
.pic {
  flex: none;
  width: 72px;
  height: 72px;
  padding: 4px;
  border-radius: 12px;
  background: #f9fafb;
  object-fit: contain;
  /* 흰 배경 제품 사진이 회색 칸에 자연스럽게 섞이게 */
  mix-blend-mode: multiply;
}
.pic.none { display: grid; place-items: center; font-size: 30px; mix-blend-mode: normal; }
.body { flex: 1; min-width: 0; }
.name { display: flex; align-items: center; gap: 6px; font-size: 16px; font-weight: 600; }
.name span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 한국 반입 금지·주의 배지 */
.tag { flex: none; padding: 1px 6px; border-radius: 6px; font-size: 11px; font-weight: 700; line-height: 1.6; }
.tag.ban { background: #ffeceb; color: var(--red); }
.tag.caution { background: #fff4e0; color: #d97706; }
.row.banned .pic { opacity: 0.45; }
.sub { margin-top: 1px; font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp { display: flex; align-items: baseline; gap: 6px; margin-top: 6px; white-space: nowrap; }
.pp b { font-size: 16px; font-weight: 700; }
.pp .krw { font-size: 13px; color: var(--sub); }
.pp .where { margin-left: auto; overflow: hidden; text-overflow: ellipsis; font-size: 12px; color: var(--faint); }

/* 담기 버튼: 담기 전엔 회색 +, 담으면 파란 체크 */
.pick {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--field);
  color: var(--faint);
  cursor: pointer;
}
.pick svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.pick:active { transform: scale(0.92); }
.row.in .pick { background: var(--blue); color: #fff; }

.empty { padding: 48px 16px; text-align: center; color: var(--sub); }

footer { max-width: 640px; margin: 0 auto; padding: 20px 18px calc(32px + env(safe-area-inset-bottom)); font-size: 12px; color: var(--faint); }
footer p + p { margin-top: 8px; }

/* 제품 상세: 점원에게 보여 주는 화면 */
#viewer {
  width: min(92vw, 480px);
  max-height: 90vh;
  max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: #fff;
  outline: none;
  overflow: auto;
}
#viewer::backdrop { background: rgba(0, 0, 0, 0.55); }
#viewer .photo { display: grid; place-items: center; height: min(45vh, 45dvh, 360px); padding: 20px; background: #f9fafb; }
#viewer .photo img { max-width: 100%; max-height: 100%; object-fit: contain; mix-blend-mode: multiply; }
#viewer .photo .none { font-size: 80px; }
#viewer .info { padding: 18px 20px 20px; }
#viewer .ja { font-size: 24px; font-weight: 700; line-height: 1.3; letter-spacing: -0.02em; word-break: keep-all; }
#viewer .ko { margin-top: 4px; color: var(--sub); }
#viewer .ask { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: var(--field); font-size: 17px; font-weight: 600; }
#viewer .ask small { display: block; margin-top: 2px; font-size: 12px; font-weight: 500; color: var(--sub); }
#viewer dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 16px 0 0; font-size: 14px; }
#viewer dt { color: var(--sub); }
#viewer dd { margin: 0; text-align: right; font-weight: 600; }
#viewer .actions, #cart .actions { display: flex; gap: 8px; margin-top: 18px; }
#viewer .actions > *, #cart .actions button {
  display: grid;
  place-items: center;
  flex: 1;
  height: 50px;
  border: 0;
  border-radius: 14px;
  background: var(--field);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
#viewer .actions .primary, #cart .actions .primary { background: var(--blue); color: #fff; }
#viewer .actions .primary.in { background: var(--blue-soft); color: var(--blue); }

/* 화면 아래에 떠 있는 쇼핑 목록 요약 */
#cartbar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 616px;
  margin: 0 auto;
  padding: 14px 16px;
  border: 0;
  border-radius: 14px;
  background: var(--text);
  color: #fff;
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
#cartbar[hidden] { display: none; }
#cartbar .ttl { font-weight: 700; }
#cartbar .sum { flex: 1; color: #c5ccd6; }
#cartbar .flag { font-size: 13px; font-weight: 600; color: #7dd3a0; }
body:has(#cartbar:not([hidden])) footer { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

#cart {
  width: min(94vw, 520px);
  max-height: 88vh;
  max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  padding: 0;
  border: 0;
  border-radius: 20px;
  outline: none;
}
#cart::backdrop { background: rgba(0, 0, 0, 0.45); }
#cart .content { padding: 22px 20px 18px; }
#cart h2 { margin: 0 0 14px; font-size: 19px; }
#cart h2:focus { outline: none; }
#cart h2 small { font-size: 14px; font-weight: 500; color: var(--sub); }
.meter { margin-bottom: 4px; }
.meter p { display: flex; justify-content: space-between; font-size: 14px; color: var(--sub); }
.meter b { color: var(--text); font-weight: 600; }
.meter i { display: block; height: 6px; margin-top: 5px; border-radius: 3px; background: linear-gradient(var(--blue), var(--blue)) left / var(--w) 100% no-repeat, #e5e8eb; }
#cart .items { list-style: none; margin: 12px 0 0; padding: 0; }
#cart .items li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
#cart .items label { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; }
#cart .items input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--blue); }
#cart .items .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#cart .items .nm small { color: var(--faint); }
#cart .items li.bought .nm { color: var(--faint); text-decoration: line-through; }
#cart .items .yen { flex: none; color: var(--sub); }
#cart .del { flex: none; width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; color: var(--faint); font-size: 14px; cursor: pointer; }
#cart .note { margin-top: 10px; font-size: 12px; color: var(--faint); }

/* 상세 화면 경고 */
#viewer .alert { margin-top: 14px; padding: 12px 14px; border-radius: 12px; font-size: 14px; line-height: 1.5; }
#viewer .alert b { display: block; margin-bottom: 2px; font-size: 15px; }
#viewer .alert.ban { background: #ffeceb; color: #b4232b; }
#viewer .alert.caution { background: #fff4e0; color: #9a5b00; }
#cart .items .tag { margin-right: 4px; vertical-align: 1px; }
#cart .note.ban { color: var(--red); }

/* 면세·반입 팁 */
/* 팁 창 */
#tips {
  width: min(94vw, 600px);
  max-height: 90vh;
  max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: #fff;
  outline: none;
}
#tips::backdrop { background: rgba(0, 0, 0, 0.45); }
#tips .close {
  position: sticky;
  top: 10px;
  float: right;
  z-index: 1;
  width: 34px;
  height: 34px;
  margin: 10px 10px 0 0;
  border: 0;
  border-radius: 50%;
  background: var(--field);
  color: var(--sub);
  font-size: 15px;
  cursor: pointer;
}
/* 창이 열릴 때 닫기 버튼에 자동으로 잡히는 포커스 테두리는 숨긴다 */
#tips .close:focus:not(:focus-visible) { outline: none; }
.tips { padding: 6px 20px 20px; font-size: 14px; line-height: 1.6; }
.tips section { padding: 16px 0; }
.tips section + section { border-top: 1px solid #e5e8eb; }
.tips h2 { margin: 0 0 8px; font-size: 18px; letter-spacing: -0.02em; }
.tips h2 small { margin-left: 4px; font-size: 13px; font-weight: 500; color: var(--sub); }
.tips .lead { color: var(--text); }
.tips ol, .tips ul { margin: 8px 0 0; padding-left: 20px; }
.tips li + li { margin-top: 6px; }
.tips .callout { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: #ffeceb; color: #8a1c22; }
.tips .callout ul { margin-top: 4px; }
.tips .tip { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--blue-soft); color: #1b4fa0; }
.tips table { width: 100%; margin-top: 4px; border-collapse: collapse; }
.tips th, .tips td { padding: 9px 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tips th { width: 64px; color: var(--sub); font-weight: 500; }
.tips .src { padding-top: 14px; border-top: 1px solid #e5e8eb; font-size: 12px; color: var(--faint); }
.tips .src a { color: inherit; }

/* 쇼핑 목록: 구매처별 묶음 */
#cart .store { margin-top: 18px; }
#cart .store h3 { display: flex; align-items: baseline; gap: 6px; margin: 0; font-size: 15px; }
#cart .store h3 small { color: var(--sub); font-weight: 500; font-size: 13px; }
#cart .store h3 em { margin-left: auto; padding: 2px 8px; border-radius: 6px; background: var(--field); color: var(--sub); font-size: 12px; font-style: normal; font-weight: 600; }
#cart .store h3 em.ok { background: #e6f7ed; color: #1a8a4a; }
#cart .store .items { margin-top: 6px; }
#cart .note b { color: var(--sub); }
