/* 외부 웹폰트 없이 시스템 폰트만 사용 (중국 접속 속도) */
:root {
  --ink: #1a1a1a;
  --ink-2: #555;
  --ink-3: #8a8a8a;
  --line: #e6e6e6;
  --bg: #ffffff;
  --bg-2: #f6f5f3;
  --accent: #b3261e;
  --accent-ink: #ffffff;
  --ok: #1e7a46;
  --radius: 10px;
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px 40px; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 16px; background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 19px; font-weight: 700; letter-spacing: .04em; text-decoration: none; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.lang-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.cart-btn { position: relative; display: grid; place-items: center; width: 40px; height: 40px; }
.badge {
  position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px;
  display: grid; place-items: center;
}
.badge[hidden] { display: none; }
.notice { background: var(--ink); color: #fff; text-align: center; font-size: 13px; padding: 7px 16px; }

/* 카테고리 탭 */
.cats { display: flex; gap: 8px; overflow-x: auto; padding: 14px 0 6px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cat {
  flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 7px 15px; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.cat.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* 상품 그리드 */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 12px; padding-top: 12px; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px 18px; } }
@media (min-width: 980px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.card { text-decoration: none; display: block; }
.thumb { position: relative; aspect-ratio: 3 / 4; background: var(--bg-2); border-radius: 6px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .tag {
  position: absolute; left: 8px; top: 8px; background: rgba(0,0,0,.72); color: #fff;
  font-size: 12px; padding: 3px 8px; border-radius: 4px;
}
.card .name { margin: 9px 0 3px; font-size: 14px; line-height: 1.4; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.price { font-weight: 700; font-size: 15px; }
.price .was { color: var(--ink-3); font-weight: 400; text-decoration: line-through; font-size: 13px; margin-left: 6px; }
.empty { text-align: center; color: var(--ink-3); padding: 80px 0; }

/* 상세 */
.detail { display: grid; gap: 22px; padding-top: 16px; }
@media (min-width: 820px) { .detail { grid-template-columns: 1.1fr 1fr; gap: 40px; padding-top: 28px; } }
.gallery { position: relative; margin: 0 -16px; }
@media (min-width: 820px) { .gallery { margin: 0; } }
.main-img { width: 100%; height: auto; min-height: 200px; background: var(--bg-2); }
div.main-img { aspect-ratio: 3 / 4; }
@media (min-width: 820px) { .main-img { border-radius: 8px; } }
/* 본문: 설명 + 상세 이미지 세로 나열 */
.detail-body { max-width: 760px; margin: 36px auto 0; border-top: 1px solid var(--line); }
.detail-body .desc { margin: 0; padding: 22px 0; border-top: 0; }
.detail-body img { width: calc(100% + 32px); max-width: none; height: auto; margin: 0 -16px; }
@media (min-width: 792px) { .detail-body img { width: 100%; margin: 0; } }
.info h1 { font-size: 20px; margin: 0 0 10px; line-height: 1.4; font-weight: 600; }
.info .price { font-size: 22px; }
.opt { margin-top: 20px; }
.opt-label { font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 8px 14px;
  font-size: 14px; cursor: pointer; min-width: 52px;
}
.chip.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); font-weight: 600; }
.chip:disabled { color: var(--ink-3); text-decoration: line-through; cursor: not-allowed; background: var(--bg-2); }
.chip small { color: var(--accent); margin-left: 4px; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 6px; }
.qty button { width: 38px; height: 38px; border: 0; background: none; font-size: 18px; cursor: pointer; }
.qty span { min-width: 34px; text-align: center; }
.desc { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line);
  white-space: pre-wrap; line-height: 1.75; font-size: 14px; color: var(--ink-2); }
.buybar { display: flex; gap: 10px; margin-top: 22px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 48px; padding: 0 20px; border-radius: 8px; border: 1px solid var(--ink);
  background: #fff; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--ink); color: #fff; }
.btn.red { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.block { width: 100%; }
.buybar .btn { flex: 1; }
.line-total { margin-top: 16px; font-size: 14px; color: var(--ink-2); }
.line-total b { color: var(--ink); font-size: 17px; }

/* 하단 고정 구매바 + 옵션 시트 */
.stickybar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; gap: 10px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.97); border-top: 1px solid var(--line);
  transform: translateY(110%); transition: transform .2s ease;
}
.stickybar.show { transform: none; }
.stickybar .btn { flex: 1; }
body.has-bar .footer { padding-bottom: 90px; }
.sheet-dim { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.45); }
.sheet-dim[hidden] { display: none; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-width: 640px; margin: 0 auto; max-height: 82vh; display: flex; flex-direction: column;
  background: #fff; border-radius: 16px 16px 0 0;
  transform: translateY(105%); transition: transform .22s ease; visibility: hidden;
}
.sheet.open { transform: none; visibility: visible; }
.sheet-head { display: grid; grid-template-columns: 72px 1fr auto; gap: 12px; align-items: center; padding: 16px 16px 12px; border-bottom: 1px solid var(--line); }
.sheet-head img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; background: var(--bg-2); }
.sheet-name { font-size: 14px; line-height: 1.4; margin-bottom: 4px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sheet-x { border: 0; background: none; font-size: 18px; width: 36px; height: 36px; cursor: pointer; color: var(--ink-3); align-self: start; }
.sheet-body { overflow-y: auto; padding: 0 16px 8px; }
.sheet-btns { margin: 0; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }

.to-top {
  position: fixed; right: 16px; bottom: 24px; z-index: 29;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(255,255,255,.95); box-shadow: 0 2px 10px rgba(0,0,0,.1);
  display: grid; place-items: center; cursor: pointer; transition: bottom .2s ease;
}
.to-top[hidden] { display: none; }
body.has-bar .to-top { bottom: calc(82px + env(safe-area-inset-bottom)); }
body.has-bar .toast { bottom: calc(90px + env(safe-area-inset-bottom)); }

/* 장바구니 / 주문 */
.page-title { font-size: 20px; margin: 22px 0 14px; }
.cart-item { display: grid; grid-template-columns: 76px 1fr auto; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: start; }
.cart-item img { width: 76px; height: 100px; object-fit: cover; border-radius: 5px; background: var(--bg-2); }
.cart-item .nm { font-size: 14px; line-height: 1.4; }
.cart-item .op { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.cart-item .rm { border: 0; background: none; color: var(--ink-3); cursor: pointer; font-size: 13px; padding: 4px; }
.cart-item .qty { margin-top: 8px; }
.cart-item .qty button { width: 30px; height: 30px; font-size: 15px; }
.summary { margin-top: 18px; background: var(--bg-2); border-radius: var(--radius); padding: 16px; }
.summary .row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; color: var(--ink-2); }
.summary .row.total { color: var(--ink); font-weight: 700; font-size: 18px; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 12px; }
.narrow { max-width: 560px; margin: 0 auto; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.field label i { color: var(--accent); font-style: normal; }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px; font-size: 15px; background: #fff;
}
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--ink); }
.hint { font-size: 12px; color: var(--ink-3); margin-top: 5px; }

.done { text-align: center; padding-top: 28px; }
.done .check { width: 56px; height: 56px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; margin: 0 auto 14px; font-size: 28px; }
.order-no { font-size: 24px; font-weight: 700; letter-spacing: .04em; margin: 6px 0 2px; }
.pay-box { margin: 22px 0; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; text-align: center; }
.pay-box .amt { font-size: 28px; font-weight: 800; color: var(--accent); margin: 4px 0 12px; }
.pay-box img { width: 220px; height: 220px; object-fit: contain; margin: 10px auto; }
.pay-box p { font-size: 14px; line-height: 1.7; color: var(--ink-2); white-space: pre-wrap; text-align: left; }
.copy { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; margin-left: 6px; }
.status { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 13px; background: var(--bg-2); }
.status.paid, .status.shipped { background: #e6f2ea; color: var(--ok); }
.status.done { background: #eee; }
.status.cancelled { background: #fbe9e7; color: var(--accent); }

.footer { border-top: 1px solid var(--line); padding: 22px 16px; text-align: center; font-size: 13px; color: var(--ink-3); display: flex; gap: 16px; justify-content: center; }
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); z-index: 50;
  background: rgba(0,0,0,.85); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px; max-width: calc(100% - 32px);
}
.toast[hidden] { display: none; }
.err { color: var(--accent); font-size: 13px; margin: 8px 0; }
.back { display: inline-block; margin-top: 14px; font-size: 14px; color: var(--ink-2); text-decoration: none; }
