:root {
  --bg: #f5f4f1;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #6c6c72;
  --line: #e2e1dc;
  --accent: #e0503a;
  --accent-ink: #ffffff;
  --ok: #1d8a4b;
  --radius: 14px;
  --badge-h: 0px;  /* 호스팅 배지가 하단을 가릴 때 그 높이만큼 (Netlify 무료 56px) */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131314;
    --card: #1e1e20;
    --text: #f1f1f3;
    --muted: #a1a1a8;
    --line: #333336;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  -webkit-text-size-adjust: 100%;
}
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.top h1 { margin: 0; font-size: 18px; }
.top .spacer { flex: 1; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #f3c94b; color: #3a2d00; }
main { max-width: 960px; margin: 0 auto; padding: 10px 16px calc(120px + var(--badge-h)); }
.hint { margin: 0 0 8px; color: var(--muted); font-size: 13px; line-height: 1.4; }
.empty { text-align: center; color: var(--muted); padding: 48px 0; }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.card img, .card .noimg { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--line); }
.card .noimg { display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.card .body { padding: 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card h2 { margin: 0; font-size: 15px; font-weight: 600; word-break: keep-all; }
.pid { font-size: 12px; color: var(--muted); }
.price { font-weight: 700; margin-bottom: 6px; }
.card .btn { margin-top: auto; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 10px; padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.on { background: transparent; border-color: var(--ok); color: var(--ok); }
.btn.small { padding: 6px 10px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
a.btn { text-decoration: none; text-align: center; display: inline-flex; align-items: center; justify-content: center; }
.btn.kakao { background: #fee500; border-color: #fee500; color: #191600; }
.reqbtn { width: 100%; margin-bottom: 10px; padding: 8px 14px; border-style: dashed; font-weight: 400; }
.reqbtn b { color: var(--accent); }
.tag { font-size: 12px; padding: 1px 6px; border-radius: 6px; background: var(--line); color: var(--muted); margin-right: 4px; }

.cartbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px calc(12px + var(--badge-h) + env(safe-area-inset-bottom));  /* Netlify 무료 배지(오른쪽 아래 고정) 자리 비움 */
  background: var(--card); border-top: 1px solid var(--line);
}

dialog {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  border: none; border-radius: 18px; padding: 0;
  background: var(--card); color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.step { padding: 20px 16px 16px; }
.step h3 { margin: 0 0 12px; font-size: 18px; }
.step p { margin: 0 0 12px; }
.actions { display: flex; gap: 8px; margin-top: 16px; }
.actions .btn { flex: 1; }

label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 4px; }
label .opt { font-weight: 400; color: var(--muted); }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number] {
  width: 100%; padding: 11px 12px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: flex; gap: 8px; }
.row > input { flex: 1; min-width: 0; }
.note { font-size: 13px; color: var(--muted); margin-top: 4px; }
.err { color: var(--accent); font-size: 14px; min-height: 1.2em; margin-top: 8px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 4px; }
.check a { color: inherit; }
#postcodeBox { height: 420px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-top: 8px; }

.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list .name { flex: 1; word-break: keep-all; }
.total { display: flex; justify-content: space-between; font-weight: 700; font-size: 17px; padding-top: 10px; }
.info { background: var(--bg); border-radius: 10px; padding: 12px; font-size: 15px; }
.info div { display: flex; gap: 8px; padding: 2px 0; }
.info dt, .info .k { color: var(--muted); min-width: 72px; }
.bank { background: var(--bg); border-radius: 12px; padding: 14px; margin: 12px 0; }
.bank .acc { font-size: 20px; font-weight: 700; letter-spacing: .3px; }
.bank .row { align-items: center; justify-content: space-between; margin-top: 6px; }

.toast {
  position: fixed; left: 50%; bottom: calc(88px + var(--badge-h)); transform: translateX(-50%); z-index: 50;
  background: #1c1c1e; color: #fff; padding: 10px 16px; border-radius: 99px; font-size: 14px;
  opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; }

/* 관리자 */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 8px; font-size: 17px; }
.preview { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; margin-top: 8px; display: block; }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; background: var(--line); flex: none; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
td.num { text-align: right; }
.login { max-width: 360px; margin: 48px auto; }
.switchrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switchrow .note { margin: 0; }
.switch { position: relative; width: 56px; height: 32px; flex: none; margin: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(24px); }
.seg { display: flex; gap: 8px; }
.seg label { flex: 1; margin: 0; font-weight: 600; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; text-align: center; padding: 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.seg input:checked + span { border-color: var(--accent); color: var(--accent); background: transparent; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.state { font-size: 12px; padding: 1px 6px; border-radius: 6px; margin-left: 2px; }
.state.on { background: rgba(29, 138, 75, .15); color: var(--ok); }
.state.off { background: var(--line); color: var(--muted); }
.state.sold { background: rgba(224, 80, 58, .15); color: #e5322d; }
.btns { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

/* 품절 */
.card .media { position: relative; }
.soldout { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255, 255, 255, .55); color: #e5322d; font-size: 28px; font-weight: 800; letter-spacing: 4px; }
@media (prefers-color-scheme: dark) { .soldout { background: rgba(0, 0, 0, .5); } }
.stock { font-size: 12px; color: var(--accent); }
.qty { display: inline-flex; align-items: center; gap: 6px; }
.qty button { width: 30px; height: 30px; padding: 0; }
.qty b { min-width: 18px; text-align: center; }
.closed { text-align: center; padding: 40px 16px; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }

/* 포장 카드 */
#pack select { flex: 1; min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); font: inherit; }
.packbtns { margin: 8px 0; }
.packbtns .btn { flex: 1; }
.packgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.packgrid img { width: 100%; border: 1px solid var(--line); border-radius: 8px; display: block; background: #fff; }

/* 구매자 상품 카드: 사진 + 가격·담기 한 줄 */
.card .body { flex-direction: row; align-items: center; justify-content: space-between; gap: 4px; padding: 8px; }
.card .price { margin: 0; white-space: nowrap; font-size: 15px; }
.card .body .btn { margin: 0; padding: 5px 10px; flex-shrink: 0; }
.card .noimg { padding: 8px; text-align: center; word-break: keep-all; color: var(--text); font-size: 14px; }
.sizerow { margin-bottom: 6px; }
.sizerow input { flex: 1; min-width: 0; }
.sizerow .btn { flex-shrink: 0; }

/* 사이즈 선택 */
.sizeimg { width: 100%; max-height: 40vh; object-fit: contain; border-radius: 10px; background: var(--line); display: block; margin-bottom: 8px; }
.sizelist { display: flex; flex-direction: column; gap: 8px; }
.sizeopt { display: flex; align-items: center; gap: 8px; text-align: left; }
.sizeopt span:first-child { flex: 1; }
.sizeopt .pid { min-width: 44px; text-align: right; }
.sizeopt.on { border-color: var(--ok); }

/* 주문 안내 동의 */
.agree { margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.agree details { margin-top: 8px; }
.agree summary { cursor: pointer; font-size: 14px; color: var(--muted); }
.agree ul { margin: 8px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.5; }
.agree li { margin-bottom: 6px; word-break: keep-all; }
.agree a { color: inherit; }
textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); font: inherit; font-size: 15px; resize: vertical; }

/* 접히는 패널 (관리자 구매자 화면 문구) */
.fold > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before { content: "▸"; color: var(--muted); }
.fold[open] > summary::before { content: "▾"; }
.fold > summary h2 { margin: 0; }
.fold[open] > summary { margin-bottom: 8px; }
