/* 데모마켓 공통 스타일 */
:root {
  --brand: #7c3aed; --brand-dark: #5b21b6; --text: #111827; --muted: #6b7280; --line: #e5e7eb;
  --bg: #f9fafb; --card: #fff; --danger: #dc2626; --ok: #16a34a; --warn: #d97706; --radius: 10px;
}
* { box-sizing: border-box; }
/* 머리글이 80px 에서 줄 때 스크롤 고정(anchoring)이 scrollY 를 되돌려 머리글이 끝없이 커졌다 줄었다 하는 것을 막는다 */
html { overflow-anchor: none; }
body { margin: 0; font: 15px/1.6 system-ui, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif; color: var(--text); background: var(--bg); }
body.no-scroll { overflow: hidden; }
a { color: inherit; }
main { max-width: 1120px; margin: 0 auto; padding: 24px 16px 80px; min-height: 60vh; }
h1 { font-size: 24px; margin: 8px 0 20px; }
.muted { color: var(--muted); }
.error-text { color: var(--danger); font-size: 13px; margin: 4px 0 0; }
.ok-text { color: var(--ok); font-size: 13px; margin: 4px 0 0; }
[hidden] { display: none !important; }

/* 머리글 */
#site-header { position: sticky; top: 0; z-index: 500; background: #fff; border-bottom: 1px solid var(--line); transition: height .2s; }
.header-inner { max-width: 1120px; margin: 0 auto; height: 64px; padding: 0 16px; display: flex; align-items: center; gap: 24px; transition: height .2s; }
#site-header.stuck { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
#site-header.stuck .header-inner { height: 48px; }
.logo { font-weight: 800; font-size: 20px; color: var(--brand); text-decoration: none; }
.gnb { display: flex; gap: 20px; flex: 1; justify-content: center; }
.gnb a { text-decoration: none; font-weight: 600; }
.gnb-item { position: relative; padding: 8px 0; }
.gnb-item .sub { display: none; position: absolute; top: 100%; left: -12px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 0; min-width: 140px; box-shadow: 0 6px 16px rgba(0,0,0,.08); }
.gnb-item.has-sub:hover .sub, .gnb-item.has-sub:focus-within .sub { display: block; }
.sub a { display: block; padding: 6px 14px; font-weight: 400; }
.sub a:hover { background: var(--bg); }
.util { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.util a { text-decoration: none; }
.link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; color: inherit; }
.badge { display: inline-block; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center; margin-left: 2px; vertical-align: top; }
.bell-wrap { position: relative; }
.bell { background: none; border: 0; font-size: 18px; cursor: pointer; }
.bell-list { position: absolute; right: 0; top: 32px; width: 280px; max-height: 300px; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 16px rgba(0,0,0,.1); }
.bell-list a, .bell-list .note { display: block; margin: 0; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.bell-list a.unread, .bell-list .note.unread { background: #f5f3ff; }
.bell-list .empty { padding: 12px; margin: 0; color: var(--muted); }
.hamburger { display: none; background: none; border: 0; font-size: 22px; cursor: pointer; }
@media (max-width: 768px) {
  .hamburger { display: block; }
  .gnb { position: fixed; top: 0; left: 0; bottom: 0; width: 240px; flex-direction: column; justify-content: flex-start; background: #fff; padding: 72px 20px; transform: translateX(-100%); transition: transform .3s; box-shadow: 4px 0 16px rgba(0,0,0,.1); }
  #site-header.drawer-open .gnb { transform: none; }
  .gnb-item .sub { position: static; display: block; border: 0; box-shadow: none; }
  .util .hello { display: none; }
}

/* 바닥글 · 맨 위로 · 쿠키 띠 */
#site-footer { border-top: 1px solid var(--line); background: #fff; }
.footer-inner { max-width: 1120px; margin: 0 auto; padding: 24px 16px; color: var(--muted); font-size: 13px; }
.to-top { position: fixed; right: 20px; bottom: 88px; z-index: 400; border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 6px 12px; cursor: pointer; }
.cookie-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 800; background: #1f2937; color: #fff; display: flex; align-items: center; justify-content: center; gap: 16px; padding: 16px; }
.cookie-bar p { margin: 0; }

/* 버튼 · 입력 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; cursor: pointer; text-decoration: none; color: var(--text); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.block { width: 100%; }
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.form { max-width: 520px; display: grid; gap: 16px; }
.form-row { display: grid; gap: 6px; }
.form-row > label, .form-row > .label { font-weight: 600; font-size: 14px; }
.req::after { content: ' *'; color: var(--danger); }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=date], input[type=search], input[type=number], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 8px; font: inherit; background: #fff;
}
textarea { min-height: 160px; resize: vertical; }
input:disabled { background: #f3f4f6; color: var(--muted); }
.inline { display: flex; gap: 8px; align-items: center; }
.inline > input { flex: 1; }
.choices { display: flex; flex-wrap: wrap; gap: 14px; }
.choices label { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }
.counter { text-align: right; font-size: 12px; color: var(--muted); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { width: 40px; height: 22px; appearance: none; background: #d1d5db; border-radius: 11px; position: relative; cursor: pointer; transition: background .2s; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .2s; }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { left: 21px; }

/* 카드 · 표 · 탭 · 아코디언 · 페이지 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
table.list { width: 100%; border-collapse: collapse; background: #fff; }
table.list th, table.list td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
table.list th { background: #f3f4f6; font-weight: 600; }
table.list tr.notice { background: #fffbeb; }
table.list tr.answer td { background: #f5f3ff; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; }
.tabs [role=tab] { background: none; border: 0; padding: 10px 16px; font: inherit; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tabs [role=tab][aria-selected=true] { border-color: var(--brand); color: var(--brand); font-weight: 700; }
.accordion .q { width: 100%; text-align: left; background: #fff; border: 0; border-bottom: 1px solid var(--line); padding: 14px 12px; font: inherit; cursor: pointer; display: flex; justify-content: space-between; }
.accordion .q[aria-expanded=true] { font-weight: 700; }
.accordion .a { padding: 12px 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
.pager { display: flex; gap: 4px; justify-content: center; margin-top: 20px; }
.pager button { min-width: 36px; height: 36px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; }
.pager button[aria-current=page] { background: var(--brand); color: #fff; border-color: var(--brand); }
.pager button:disabled { opacity: .4; cursor: not-allowed; }
.empty-state { text-align: center; padding: 60px 16px; color: var(--muted); }
.status { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.status.결제완료 { background: #dbeafe; color: #1d4ed8; }
.status.배송중 { background: #fef3c7; color: #b45309; }
.status.배송완료 { background: #dcfce7; color: #15803d; }
.status.주문취소 { background: #f3f4f6; color: #6b7280; }
.skeleton { background: linear-gradient(90deg, #eee 25%, #f5f5f5 50%, #eee 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* 모달 · 토스트 */
.modal-backdrop { position: fixed; inset: 0; z-index: 1000; background: rgba(17,24,39,.5); display: flex; align-items: center; justify-content: center; padding: 16px; opacity: 0; transition: opacity .3s; }
.modal-backdrop.open { opacity: 1; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 440px; max-height: 90vh; display: flex; flex-direction: column; transform: translateY(12px); transition: transform .3s; }
.modal-backdrop.open .modal { transform: none; }
.modal.wide { max-width: 720px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-x { background: none; border: 0; font-size: 24px; cursor: pointer; line-height: 1; }
.modal-body { padding: 20px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; }
#toast-box { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); z-index: 1100; display: grid; gap: 8px; }
.toast { background: #111827; color: #fff; padding: 12px 20px; border-radius: 24px; animation: toast-in .3s ease-out; transition: opacity .3s; }
.toast.leaving { opacity: 0; }
@keyframes toast-in { from { transform: translateY(20px); opacity: 0; } }

/* 상품 카드 */
.products { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 768px) { .products { grid-template-columns: repeat(2, 1fr); } }
.product { position: relative; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; display: block; }
.product img { width: 100%; aspect-ratio: 1; display: block; object-fit: cover; }
.product .info { padding: 10px 12px; }
.product .name { font-weight: 600; margin: 0 0 4px; }
.product .origin { text-decoration: line-through; color: var(--muted); font-size: 13px; margin-right: 6px; }
.product .sale { color: var(--danger); font-weight: 700; }
.product .rate { color: var(--danger); font-weight: 700; margin-right: 4px; }
.product.soldout::after { content: '품절'; position: absolute; inset: 0; background: rgba(107,114,128,.6); color: #fff; font-size: 22px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.product-skel { aspect-ratio: .75; }
