:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --subtle: #f2f1ef;
  --text: #18181b;
  --muted: #71717a;
  --faint: #a1a1aa;
  --line: #ebeae7;
  --ink: #18181b;
  --on-ink: #ffffff;
  --sale: #e5484d;
  --kakao: #fee500;
  --kakao-text: #191600;
  --warn: #f08c00;
  --ok: #12a150;
  --radius: 16px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f10;
    --surface: #18181b;
    --subtle: #222226;
    --text: #f4f4f5;
    --muted: #a1a1aa;
    --faint: #71717a;
    --line: #27272a;
    --ink: #f4f4f5;
    --on-ink: #18181b;
    --sale: #ff6369;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  line-height: 1.5;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; }
button, input, select { font: inherit; color: inherit; letter-spacing: inherit; }
svg { display: block; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 640px) { .wrap { padding: 0 24px; } }

/* ---------- Header ---------- */
.hero { padding: 28px 0 14px; }
@media (min-width: 640px) { .hero { padding: 48px 0 20px; } }
.hero-inner { display: flex; align-items: center; gap: 14px; }
.avatar {
  flex: none; width: 56px; height: 56px; border-radius: 18px;
  display: grid; place-items: center; font-size: 28px;
  background: linear-gradient(135deg, #fff4c2, #ffe0e0);
}
@media (prefers-color-scheme: dark) { .avatar { background: linear-gradient(135deg, #3a3420, #3a2324); } }
.hero h1 { margin: 0; font-size: clamp(22px, 5vw, 30px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.2; }
.tagline { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
@media (min-width: 640px) { .tagline { font-size: 15px; } }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.meta span {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; color: var(--muted);
  padding: 5px 10px; border-radius: 999px; background: var(--subtle);
}

/* ---------- Toolbar ---------- */
.toolbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px);
  padding: 10px 0;
  transition: box-shadow .2s;
}
.toolbar.stuck { box-shadow: 0 1px 0 var(--line); }
.row { display: flex; gap: 8px; }
.search {
  position: relative; flex: 1; min-width: 0;
}
.search svg {
  position: absolute; left: 14px; top: 50%; translate: 0 -50%;
  width: 18px; height: 18px; fill: none; stroke: var(--faint); stroke-width: 2.2; stroke-linecap: round;
}
.search input {
  width: 100%; height: 44px; font-size: 16px;
  padding: 0 14px 0 40px; border-radius: 12px;
  border: 0; background: var(--subtle); outline: none;
  transition: box-shadow .15s, background .15s;
}
.search input::placeholder { color: var(--faint); }
.search input:focus { background: var(--surface); box-shadow: 0 0 0 2px var(--ink); }
.search input::-webkit-search-cancel-button { filter: grayscale(1); }
.select { position: relative; flex: none; }
.select select {
  appearance: none; -webkit-appearance: none; height: 44px; font-size: 14px; font-weight: 600;
  padding: 0 32px 0 14px; border-radius: 12px; border: 0; background: var(--subtle); cursor: pointer; outline: none;
}
.select select:focus-visible { box-shadow: 0 0 0 2px var(--ink); }
.select svg {
  position: absolute; right: 10px; top: 50%; translate: 0 -50%; pointer-events: none;
  width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
}
.chips {
  display: flex; gap: 6px; margin: 10px -16px 0; padding: 0 16px;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
@media (min-width: 640px) { .chips { margin: 10px 0 0; padding: 0; flex-wrap: wrap; } }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; font-size: 14px; font-weight: 600; cursor: pointer;
  height: 34px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  transition: background .15s, color .15s, border-color .15s;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.chip.toggle { display: inline-flex; align-items: center; gap: 4px; }
.chip.toggle[aria-pressed="true"] { background: color-mix(in srgb, var(--ok) 12%, var(--surface)); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.chip-sep { flex: none; width: 1px; height: 18px; margin: 8px 2px; background: var(--line); }

/* ---------- Grid ---------- */
.count { color: var(--muted); font-size: 13px; margin: 14px 0 12px; }
.count b { color: var(--text); font-weight: 700; }
.grid {
  display: grid; column-gap: 12px; row-gap: 24px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 18px; row-gap: 32px; } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: 22px; } }

.card {
  display: flex; flex-direction: column; gap: 10px; text-align: left;
  background: none; border: 0; padding: 0; cursor: pointer;
  animation: rise .4s var(--ease) both;
}
.card:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: var(--radius); }
.thumb {
  position: relative; aspect-ratio: 1 / 1; border-radius: var(--radius); overflow: hidden;
  background: var(--subtle);
}
.thumb::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(0,0,0,.04); pointer-events: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s var(--ease); }
@media (hover: hover) { .card:hover .thumb img { transform: scale(1.04); } }
.card:active .thumb img { transform: scale(.98); }
.thumb .badge { position: absolute; top: 10px; left: 10px; }
.thumb .multi {
  position: absolute; right: 8px; bottom: 8px; font-size: 11px; font-weight: 600; color: #fff;
  background: rgba(0,0,0,.45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  padding: 2px 7px; border-radius: 999px;
}
.card.is-sold .thumb img { filter: grayscale(1) brightness(.9); opacity: .55; }
.sold-mark {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 15px; letter-spacing: 0.02em;
  background: rgba(0,0,0,.25);
}
.card-body { display: flex; flex-direction: column; gap: 3px; padding: 0 2px; }
.card-name {
  font-size: 15px; font-weight: 500; color: var(--text); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-price { display: flex; align-items: baseline; gap: 5px; flex-wrap: wrap; }
.card-price .price { font-size: 17px; font-weight: 800; letter-spacing: -0.02em; }
.card-price .off { font-size: 15px; }
.card-price .orig { font-size: 12px; }
.card.is-sold .card-name, .card.is-sold .price { color: var(--faint); }
.card-cond { font-size: 12px; color: var(--muted); }

.off { color: var(--sale); font-weight: 800; }
.off:empty, .orig:empty { display: none; }
.orig { color: var(--faint); text-decoration: line-through; }
.badge {
  display: inline-flex; align-items: center; font-size: 11px; font-weight: 700;
  height: 22px; padding: 0 8px; border-radius: 6px; color: #fff; background: var(--ok);
}
.badge.reserved { background: var(--warn); }
.badge.sold { background: #71717a; }

.empty { text-align: center; color: var(--muted); padding: 60px 0; }
.empty-icon { font-size: 32px; margin-bottom: 6px; }
.empty p { margin: 0; }
.footer { color: var(--faint); font-size: 13px; padding-top: 48px; padding-bottom: calc(110px + env(safe-area-inset-bottom)); text-align: center; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Floating Kakao button ---------- */
.fab {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 20; display: inline-flex; align-items: center; gap: 7px;
  background: var(--kakao); color: var(--kakao-text); text-decoration: none;
  font-weight: 700; font-size: 15px; height: 50px; padding: 0 20px 0 16px; border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0,0,0,.16), 0 1px 3px rgba(0,0,0,.1);
  transition: transform .2s var(--ease);
  border: 0; cursor: pointer;
}
.btn.kakao .kid { font-weight: 500; opacity: .7; }
.toast { white-space: pre-line; line-height: 1.5; }
.fab[hidden] { display: none; }
.fab:active { transform: scale(.95); }
.fab svg { width: 22px; height: 22px; fill: currentColor; }
@media (min-width: 640px) { .fab { right: 28px; bottom: 28px; } }

/* ---------- Modal / bottom sheet ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.backdrop { position: absolute; inset: 0; background: rgba(10,10,12,.5); animation: fade .25s; }
.sheet {
  position: relative; width: 100%; max-height: 94dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 24px 24px 0 0;
  animation: sheet-up .35s var(--ease);
}
.handle {
  position: absolute; top: 8px; left: 50%; translate: -50% 0; z-index: 3;
  width: 40px; height: 5px; border-radius: 999px; background: rgba(255,255,255,.7);
  box-shadow: 0 0 6px rgba(0,0,0,.15);
}
@media (min-width: 760px) {
  .modal { align-items: center; padding: 32px; }
  .sheet {
    max-width: 960px; border-radius: 24px; overflow: hidden;
    display: grid; grid-template-columns: 1.15fr 1fr; grid-template-rows: 1fr auto;
    max-height: min(680px, 90vh); animation: pop .3s var(--ease);
    box-shadow: 0 30px 80px rgba(0,0,0,.3);
  }
  .handle { display: none; }
  .gallery { grid-row: 1 / 3; }
  .detail { overflow-y: auto; padding: 32px 32px 12px !important; }
  .actions { padding: 16px 32px 28px !important; border-top: 0 !important; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }

.close {
  position: absolute; top: 14px; right: 14px; z-index: 3;
  width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center;
  background: rgba(0,0,0,.4); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.close svg { width: 18px; height: 18px; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; }
@media (min-width: 760px) {
  .close { background: var(--subtle); backdrop-filter: none; }
  .close svg { stroke: var(--text); }
}

.gallery { position: relative; background: var(--subtle); }
.slides {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
  aspect-ratio: 1 / 1; max-height: 62dvh;
}
@media (min-width: 760px) { .slides { aspect-ratio: auto; height: 100%; max-height: none; } }
.slides::-webkit-scrollbar { display: none; }
.slides img { flex: 0 0 100%; width: 100%; height: 100%; object-fit: contain; scroll-snap-align: center; }
.counter {
  position: absolute; right: 14px; bottom: 14px; font-size: 12px; font-weight: 600; color: #fff;
  background: rgba(0,0,0,.45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  padding: 3px 9px; border-radius: 999px;
}
.counter:empty { display: none; }
.dots { position: absolute; bottom: 18px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; pointer-events: none; }
.dots button { pointer-events: auto; width: 6px; height: 6px; padding: 0; border-radius: 999px; border: 0; background: rgba(255,255,255,.55); cursor: pointer; transition: width .25s var(--ease), background .25s; }
.dots button.on { width: 18px; background: #fff; }

.detail { padding: 22px 20px 8px; }
.detail-top { display: flex; align-items: center; gap: 8px; }
.cat { font-size: 13px; color: var(--muted); font-weight: 500; }
.detail h2 { margin: 10px 0 6px; font-size: 22px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.3; }
.price-line { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.price-line .price { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }
.price-line .off { font-size: 22px; }
.price-line .orig { font-size: 15px; }

.specs {
  display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 18px 0 0;
  padding: 14px 16px; border-radius: 14px; background: var(--subtle); font-size: 14px;
}
.specs:empty { display: none; }
.specs dt { color: var(--muted); }
.specs dd { margin: 0; font-weight: 600; }
.desc { white-space: pre-line; margin: 18px 0 8px; font-size: 15px; line-height: 1.7; color: var(--text); }

.actions {
  position: sticky; bottom: 0; display: flex; gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-weight: 700; font-size: 16px; cursor: pointer; height: 54px;
  padding: 0 18px; border-radius: 14px; text-decoration: none; border: 0;
  transition: transform .15s var(--ease), filter .15s;
}
.btn:active { transform: scale(.97); }
.btn.icon { width: 54px; padding: 0; background: var(--subtle); }
.btn.icon svg { width: 22px; height: 22px; fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.kakao { flex: 1; background: var(--kakao); color: var(--kakao-text); }
.btn.kakao svg { width: 20px; height: 20px; fill: currentColor; }
@media (hover: hover) { .btn.kakao:hover { filter: brightness(.97); } }
.btn.disabled { background: var(--subtle); color: var(--faint); pointer-events: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); translate: -50% 16px; z-index: 60;
  background: rgba(24,24,27,.92); color: #fff; font-size: 14px; font-weight: 500;
  padding: 12px 18px; border-radius: 12px; backdrop-filter: blur(8px);
  opacity: 0; pointer-events: none; transition: opacity .25s, translate .3s var(--ease);
  width: max-content; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; translate: -50% 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
