:root {
  --ivory: #faf7f0; --cream: #f4eee3; --beige: #ece3d3; --line: #ddd2bf;
  --ink: #1d1a16; --muted: #6f665a; --red: #c8282e; --ok: #2f7a4a; --warn: #a15c00;
  --r: 14px; --nav-h: 66px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--ivory); color: var(--ink); font-family: -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif; font-size: 17px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.app { max-width: 560px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); background: var(--ivory); }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: rgba(250,247,240,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 20px; margin: 0; letter-spacing: -0.03em; flex: 1; }
.topbar .back { border: 0; background: none; font-size: 24px; padding: 4px 8px 4px 0; }
.logo { font-weight: 900; letter-spacing: -0.04em; font-size: 22px; text-decoration: none; }
.page { padding: 16px; }
h2 { font-size: 19px; margin: 24px 0 12px; letter-spacing: -0.02em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.red { color: var(--red); }

.nav { position: fixed; z-index: 15; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 560px; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(4, 1fr); background: #fff; border-top: 1px solid var(--line); }
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; font-size: 13px; color: var(--muted); font-weight: 600; position: relative; }
.nav a .i { font-size: 22px; line-height: 1; }
.nav a[aria-current="page"] { color: var(--ink); }
.nav .count { position: absolute; top: 6px; left: 55%; background: var(--red); color: #fff; border-radius: 9px; min-width: 18px; height: 18px; font-size: 12px; line-height: 18px; text-align: center; padding: 0 4px; }
.nav .live-dot { position: absolute; top: 9px; left: 57%; width: 9px; height: 9px; border-radius: 50%; background: var(--red); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 14px 16px; border-radius: 12px; border: 1.5px solid var(--ink); background: #fff; font-weight: 700; cursor: pointer; text-decoration: none; min-height: 50px; }
.btn.primary { background: var(--ink); color: #fff; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { border-color: var(--line); }
.btn.block { width: 100%; }
.btn.big { font-size: 18px; min-height: 58px; }
.btn.sm { min-height: 40px; padding: 8px 12px; font-size: 15px; }
.btn:disabled { opacity: .4; cursor: default; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

.card { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.stack > * + * { margin-top: 10px; }
label.f { display: block; font-weight: 700; font-size: 15px; margin: 14px 0 6px; }
.input, select.input, textarea.input { width: 100%; padding: 13px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; min-height: 50px; }
textarea.input { min-height: 90px; resize: vertical; }
.input:focus { outline: 2px solid var(--ink); outline-offset: -1px; }

.badge { display: inline-block; font-size: 13px; font-weight: 800; padding: 3px 8px; border-radius: 6px; background: var(--beige); }
.badge.warn { background: #fff1dc; color: var(--warn); }
.badge.ok { background: #e7f3ea; color: var(--ok); }
.badge.muted { color: var(--muted); }
.badge.live { background: var(--red); color: #fff; }

/* 홈 */
.live-banner { display: block; position: relative; border-radius: 18px; overflow: hidden; background: var(--ink); color: #fff; text-decoration: none; padding: 20px; min-height: 150px; }
.live-banner .thumb { position: absolute; right: 0; top: 0; bottom: 0; width: 44%; background-size: cover; background-position: center; opacity: .9; }
.live-banner .txt { position: relative; max-width: 58%; }
.live-banner .title { font-size: 21px; font-weight: 800; margin: 10px 0 14px; line-height: 1.3; }
.live-banner .go { display: inline-block; background: #fff; color: var(--ink); font-weight: 800; padding: 10px 14px; border-radius: 10px; }
.upcoming { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.upcoming .card { flex: none; min-width: 220px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 10px; }
.pcard { text-decoration: none; display: block; }
.pcard .ph { aspect-ratio: 4 / 5; border-radius: 12px; background: var(--beige) center / cover no-repeat; position: relative; }
.pcard .ph .out { position: absolute; inset: 0; border-radius: 12px; background: rgba(250,247,240,.7); display: flex; align-items: center; justify-content: center; font-weight: 800; }
.pcard .nm { margin-top: 8px; font-size: 16px; line-height: 1.35; }
.pcard .pr { font-weight: 800; font-size: 17px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* 상품 상세 */
.pd-img { aspect-ratio: 4 / 5; background: var(--beige) center / cover no-repeat; margin: -16px -16px 0; }
.pd-name { font-size: 22px; font-weight: 800; margin: 16px 0 4px; letter-spacing: -0.02em; }
.pd-price { font-size: 24px; font-weight: 900; }
.pd-desc { white-space: pre-wrap; color: var(--muted); margin-top: 12px; }
.buybar { position: fixed; z-index: 14; left: 50%; transform: translateX(-50%); width: 100%; max-width: 560px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding: 10px 16px; background: rgba(250,247,240,.96); border-top: 1px solid var(--line); }

.opt-label { font-weight: 700; font-size: 15px; margin: 14px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-width: 64px; min-height: 48px; padding: 10px 14px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; font-weight: 700; cursor: pointer; }
.chip[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; }
.chip:disabled { text-decoration: line-through; opacity: .4; cursor: default; }
.qty { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; }
.qty button { width: 50px; height: 48px; border: 0; background: none; font-size: 22px; cursor: pointer; }
.qty .qty-val { min-width: 40px; text-align: center; font-weight: 800; font-size: 18px; }
.opt-stock { margin: 10px 0 0; font-size: 15px; color: var(--red); font-weight: 600; min-height: 1.2em; }

/* 장바구니/주문 */
.line { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.line:last-child { border-bottom: 0; }
.line .ph { width: 76px; height: 95px; flex: none; border-radius: 10px; background: var(--beige) center / cover no-repeat; position: relative; }
.line .ph .no { position: absolute; left: 4px; top: 4px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 800; padding: 1px 6px; border-radius: 5px; }
.line .info { flex: 1; min-width: 0; }
.line .nm { font-weight: 700; }
.line .op { color: var(--muted); font-size: 15px; }
.line .pr { font-weight: 800; margin-top: 2px; }
.line .tools { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.line .tools .qty button { width: 40px; height: 38px; font-size: 18px; }
.line .tools .qty .qty-val { min-width: 30px; font-size: 16px; }
.check { width: 26px; height: 26px; accent-color: var(--ink); flex: none; margin-top: 34px; }
.link-btn { border: 0; background: none; color: var(--muted); text-decoration: underline; font-size: 15px; padding: 6px; cursor: pointer; }
.hold { font-size: 13px; color: var(--warn); margin-top: 4px; }
.sumbox { margin-top: 14px; }
.sumbox .r { display: flex; justify-content: space-between; padding: 4px 0; }
.sumbox .total { font-size: 20px; font-weight: 900; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 10px; }
.shipbar { font-size: 15px; margin: 12px 0; }
.shipbar b { color: var(--red); }
.shipbar .track { height: 8px; background: var(--beige); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.shipbar .fill { height: 100%; background: var(--ink); transition: width .3s; }
.bankbox { background: var(--cream); border-radius: 12px; padding: 16px; margin-top: 12px; }
.bankbox .acc { font-size: 20px; font-weight: 900; margin: 4px 0; user-select: all; }
.order-card .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }

/* 시트 */
.sheet { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.42); display: flex; align-items: flex-end; justify-content: center; }
.sheet__panel { width: 100%; max-width: 560px; max-height: 86dvh; overflow-y: auto; background: var(--ivory); border-radius: 20px 20px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); animation: sheet-up .18s ease-out; }
.sheet__panel.center { text-align: center; }
@keyframes sheet-up { from { transform: translateY(30px); } }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet__head h3 { margin: 0; font-size: 20px; }
.sheet__head .x { border: 0; background: none; font-size: 16px; color: var(--muted); padding: 8px; cursor: pointer; }

.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(var(--nav-h) + 90px); transform: translateX(-50%); background: rgba(20,18,16,.9); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 16px; max-width: 90vw; text-align: center; }

/* 플레이어 */
.player { position: relative; width: 100%; height: 100%; background: #111; overflow: hidden; }
.player iframe, .player video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; object-fit: cover; }
.player__badge { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); color: #fff; background: rgba(0,0,0,.55); padding: 10px 16px; border-radius: 10px; white-space: nowrap; }
.player__badge:empty { display: none; }
.player__sound { position: absolute; z-index: 6; right: 12px; top: calc(70px + env(safe-area-inset-top)); border: 0; border-radius: 999px; padding: 10px 14px; background: rgba(255,255,255,.94); font-weight: 800; cursor: pointer; }

/* 라이브 화면 (전체화면) */
body.is-live .nav, body.is-live .topbar { display: none; }
body.is-live .app { padding: 0; max-width: none; background: #000; }
.live-stage { position: relative; height: 100dvh; max-width: 560px; margin: 0 auto; overflow: hidden; background: #111; }
.live-stage .player { position: absolute; inset: 0; }
.live-stage::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 120px; z-index: 2; background: linear-gradient(rgba(0,0,0,.5), transparent); pointer-events: none; }
.live-stage::after { content: ""; position: absolute; inset: auto 0 0 0; height: 58%; z-index: 2; background: linear-gradient(transparent, rgba(0,0,0,.7)); pointer-events: none; }
.live-top { position: absolute; z-index: 5; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: calc(12px + env(safe-area-inset-top)) 12px 0; color: #fff; }
.live-top .home { border: 0; width: 42px; height: 42px; border-radius: 50%; background: rgba(0,0,0,.35); color: #fff; font-size: 20px; cursor: pointer; }
.live-top .ttl { flex: 1; min-width: 0; }
.live-top .ttl b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.live-top .cartbtn { color: var(--ink); position: relative; width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(255,255,255,.94); font-size: 21px; cursor: pointer; }
.live-top .cartbtn .count { position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--red); color: #fff; font-size: 12px; font-weight: 800; line-height: 20px; padding: 0 5px; }
.chat { position: absolute; z-index: 4; left: 12px; right: 84px; bottom: 172px; color: #fff; max-height: 34vh; display: flex; flex-direction: column; justify-content: flex-end; }
.chat ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
.chat li { font-size: 16px; line-height: 1.35; text-shadow: 0 1px 3px rgba(0,0,0,.85); word-break: break-word; }
.chat li b { margin-right: 6px; opacity: .85; }
.chat li.host b { color: #ffd88a; opacity: 1; }
.chat li.pinned { background: rgba(255,255,255,.18); border-radius: 8px; padding: 4px 8px; }
.chat li.pinned::before { content: "📌 "; }
.chat.folded ul { display: none; }
.chat-toggle { align-self: flex-start; border: 0; background: rgba(0,0,0,.4); color: #fff; font-size: 13px; padding: 4px 9px; border-radius: 6px; margin-bottom: 6px; cursor: pointer; }
.now { position: absolute; z-index: 5; left: 12px; right: 12px; bottom: 84px; display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; border-radius: 14px; background: rgba(255,255,255,.97); text-align: left; box-shadow: 0 6px 20px rgba(0,0,0,.25); cursor: pointer; width: calc(100% - 24px); }
.now .ph { width: 60px; height: 72px; border-radius: 10px; flex: none; background: var(--beige) center / cover; }
.now .bd { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.now .tag { font-size: 13px; color: var(--red); font-weight: 800; }
.now .nm { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now .pr { font-size: 17px; font-weight: 900; }
.now .pr s { color: var(--muted); font-weight: 500; font-size: 14px; margin-left: 4px; }
.now .buy { background: var(--ink); color: #fff; font-weight: 800; padding: 13px 16px; border-radius: 10px; flex: none; }
.live-bar { position: absolute; z-index: 5; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); }
.live-bar form { flex: 1; }
.live-bar input { width: 100%; height: 52px; border-radius: 26px; border: 1px solid rgba(255,255,255,.55); background: rgba(0,0,0,.35); color: #fff; padding: 0 18px; }
.live-bar input::placeholder { color: rgba(255,255,255,.8); }
.live-bar .pbtn { height: 52px; padding: 0 18px; border-radius: 26px; border: 0; background: #fff; font-weight: 900; font-size: 17px; cursor: pointer; }
.ended-note { position: absolute; z-index: 5; left: 12px; right: 12px; top: calc(70px + env(safe-area-inset-top)); background: rgba(255,255,255,.95); border-radius: 12px; padding: 10px 14px; font-size: 15px; }

.plist { list-style: none; margin: 0; padding: 0; }
.plist li { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.plist li.current { background: #fff4e3; margin: 0 -16px; padding: 12px 16px; }
.plist .ph { width: 70px; height: 86px; border-radius: 10px; flex: none; background: var(--beige) center / cover; position: relative; }
.plist .ph .no { position: absolute; left: 4px; top: 4px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 800; padding: 1px 7px; border-radius: 5px; }
.plist .info { flex: 1; min-width: 0; }
.plist .nm { font-weight: 700; }
.plist .pr { font-weight: 900; }
.plist .pr s { color: var(--muted); font-weight: 500; font-size: 14px; margin-left: 4px; }
.plist .tag-now { color: var(--red); font-size: 13px; font-weight: 800; }

@media (min-width: 900px) {
  body:not(.is-live) .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

/* 사업자 정보 */
.biz { margin: 36px -16px 0; padding: 18px 16px 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.biz a { color: var(--ink); }
.sheet__panel.ask { max-width: 420px; }
.ask-msg { margin: 4px 0 14px; font-size: 16px; line-height: 1.55; white-space: normal; }
.ask-input { width: 100%; margin-bottom: 14px; }
.ask-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
