/* Apple-style (Emil Kowalski apple-design 원칙): 즉각적인 눌림 피드백, 스프링 모션, 반투명 머티리얼, 큰 타이포 위계, reduced-motion/transparency 대응 */
:root {
  --bg: #f5f5f7;
  --surface: #ececf0;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --border: rgba(0, 0, 0, .1);
  --accent: #0071e3;
  --accent-ink: #ffffff;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --shadow-hover: 0 2px 4px rgba(0,0,0,.05), 0 10px 28px rgba(0,0,0,.08);
  /* 스프링 느낌 (damping ≈1.0, response ≈0.4s 근사) */
  --spring: linear(0, .21 6%, .55 14%, .8 22%, .94 31%, 1.01 41%, 1.02 52%, 1 70%, 1);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --card: #ffffff;
  --glass: rgba(255, 255, 255, .6);
}

/* 다크모드: 사용자가 고른 테마(data-theme)가 우선, 없으면 시스템 설정을 따름 */
:root { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #2c2c2e;
  --text: #f5f5f7;
  --muted: #98989d;
  --border: rgba(255, 255, 255, .12);
  --accent: #2997ff;
  --shadow: none;
  --shadow-hover: none;
  --card: #1c1c1e;
  --glass: rgba(28, 28, 30, .6);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #000000;
    --surface: #2c2c2e;
    --text: #f5f5f7;
    --muted: #98989d;
    --border: rgba(255, 255, 255, .12);
    --accent: #2997ff;
    --shadow: none;
    --shadow-hover: none;
    --card: #1c1c1e;
    --glass: rgba(28, 28, 30, .6);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, system-ui, "SF Pro Text", "Pretendard Variable", Pretendard,
    "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

.wrap {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 72px 16px 48px;
}

/* ── 프로필 ── */
.profile { text-align: center; margin-bottom: 48px; }

.avatar {
  width: 88px;
  height: 88px;
  margin: 0 auto 20px;
  border-radius: 50%;
  object-fit: cover;
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--bg);
  background: var(--text);
  box-shadow: var(--shadow);
}

.name {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.02em;
}

.bio {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
}

/* ── 섹션 제목 ── */
.links { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }

.section {
  margin: 28px 0 0;
  padding-bottom: 0;
  padding-left: 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--muted);
}
.section:first-child { margin-top: 0; }

/* ── 링크 카드 ── */
.link {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
  padding: 12px 16px;
  background: var(--card);
  border: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -.01em;
  /* transform/opacity 위주로만 애니메이션 */
  transition: transform .4s var(--spring), box-shadow .3s var(--ease-out), background-color .2s var(--ease-out);
  will-change: transform;
}

@media (hover: hover) {
  .link:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
  .link:hover .arrow { color: var(--text); transform: translateX(3px); }
}
/* 누르는 즉시 반응 (pointer-down), 100ms ease-out */
.link:active { transform: scale(.97); transition-duration: .1s; transition-timing-function: ease-out; }
.links > * { animation: rise .6s var(--spring) backwards; }
.links > *:nth-child(1) { animation-delay: .02s; }
.links > *:nth-child(2) { animation-delay: .06s; }
.links > *:nth-child(3) { animation-delay: .10s; }
.links > *:nth-child(4) { animation-delay: .14s; }
.links > *:nth-child(5) { animation-delay: .18s; }
.links > *:nth-child(n+6) { animation-delay: .22s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.thumb {
  flex: none;
  width: 56px;
  height: 56px;
  margin: -4px 0 -4px -8px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--surface);
}

.icon { flex: none; width: 28px; height: 28px; display: grid; place-items: center; }
.icon svg { width: 22px; height: 22px; fill: currentColor; }
/* 업로드한 아이콘 */
.icon img { width: 28px; height: 28px; object-fit: contain; border-radius: 7px; }
.icon svg[fill="none"] { fill: none; }

.body { flex: 1; min-width: 0; display: grid; gap: 4px; justify-items: start; }
.label { overflow-wrap: anywhere; line-height: 1.35; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
}

.arrow {
  flex: none;
  color: var(--muted);
  font-size: 16px;
  transition: transform .4s var(--spring), color .2s var(--ease-out);
}

/* 강조 링크: 파란 CTA 버튼 */
.link.featured {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  min-height: 56px;
  justify-content: center;
  text-align: center;
  font-weight: 600;
}
.link.featured { box-shadow: 0 4px 16px color-mix(in srgb, var(--accent) 35%, transparent); }
.link.featured .body { justify-items: center; }
.link.featured .arrow, .link.featured .icon { color: inherit; }
.link.featured .badge { background: rgba(255,255,255,.2); color: #fff; }

/* ── 푸터 ── */
.foot {
  margin-top: 56px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
}

/* 관리자 하단 바 등 반투명 머티리얼 */
.bar { -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); background: var(--glass) !important; }
@media (prefers-reduced-transparency: reduce) {
  .bar { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--card) !important; }
}
@media (prefers-contrast: more) {
  :root { --border: currentColor; --muted: var(--text); }
  .link { outline: 1px solid var(--text); }
}

/* reduced motion: 슬라이드/스프링 대신 200ms 페이드 */
@media (prefers-reduced-motion: reduce) {
  .link, .arrow { transition: background-color .2s linear; }
  .link:hover, .link:active { transform: none; }
  .links > * { animation: fade .2s linear backwards; }
  @keyframes fade { from { opacity: 0; } }
}

/* 제휴(대가성) 고지 문구 */
.disclosure { margin: 28px 4px 0; text-align: center; color: var(--muted); font-size: 11.5px; line-height: 1.6; }

/* 로고 이미지 아바타: 원형 대신 둥근 사각형(스퀴클) */
img.avatar { width: 104px; height: 104px; border-radius: 0; background: none; box-shadow: none; filter: drop-shadow(0 10px 24px rgba(0,0,0,.25)); }

/* ══════════════════════════════════════════
   상단 내비게이션 (모든 페이지 공통)
   ══════════════════════════════════════════ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  border-bottom: 1px solid var(--border);
}
.topbar-in {
  max-width: 520px; margin: 0 auto; padding: 0 16px;
  height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar.wide .topbar-in { max-width: 1040px; }
.brand {
  display: inline-flex; align-items: center; gap: 9px;
  color: var(--text); text-decoration: none;
  font-size: 16px; font-weight: 700; letter-spacing: -.02em;
}
.brand img { width: 26px; height: 26px; border-radius: 7px; }
.nav-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 14px 0 12px; border-radius: 999px;
  background: var(--card); color: var(--text); text-decoration: none;
  font-size: 14px; font-weight: 600; letter-spacing: -.01em;
  box-shadow: var(--shadow), inset 0 0 0 1px var(--border);
  transition: transform .4s var(--spring), background-color .2s var(--ease-out), color .2s var(--ease-out);
}
.nav-btn svg { width: 17px; height: 17px; flex: none; }
@media (hover: hover) { .nav-btn:hover { transform: translateY(-1px); } }
.nav-btn:active { transform: scale(.96); transition-duration: .1s; }
.nav-btn[aria-current="page"] { background: var(--text); color: var(--bg); box-shadow: none; }
.nav-btn:focus-visible, .brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
/* 다크모드 전환 버튼: nav-btn과 같은 알약 재질의 원형 아이콘 버튼 */
.theme-btn {
  width: 36px; padding: 0; justify-content: center; border: 0; cursor: pointer; font: inherit;
}
.theme-btn svg { width: 18px; height: 18px; transition: transform .5s var(--spring), opacity .2s var(--ease-out); }
.theme-btn .i-sun { display: none; }
:root[data-theme="dark"] .theme-btn .i-sun { display: block; }
:root[data-theme="dark"] .theme-btn .i-moon { display: none; }
.theme-btn:active svg { transform: rotate(-30deg); }
.theme-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* 전환 순간 색이 부드럽게 바뀌도록 (theme.js가 잠깐 붙임) */
.theme-anim, .theme-anim * { transition: background-color .3s var(--ease-out), color .3s var(--ease-out), box-shadow .3s var(--ease-out) !important; }
@media (prefers-reduced-motion: reduce) { .theme-anim, .theme-anim * { transition: none !important; } }
/* 내비가 있는 페이지는 상단 여백을 줄임 */
.topbar ~ .wrap { padding-top: 48px; }

/* ══════════════════════════════════════════
   제품리스트 페이지
   ══════════════════════════════════════════ */
.topbar ~ .wrap.wide { max-width: 1040px; padding-top: 40px; }
.page-head { margin-bottom: 20px; }
.page-head .eyebrow {
  margin: 0 0 6px; color: var(--muted);
  font-size: 13px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase;
}
.page-head h1 { margin: 0; font-size: 34px; font-weight: 700; line-height: 1.1; letter-spacing: -.025em; }
.page-head p { margin: 10px 0 0; color: var(--muted); font-size: 15px; }

/* 검색 + 필터: 스크롤해도 내비 아래에 붙어 있음 */
.finder {
  position: sticky; top: 56px; z-index: 10;
  margin: 0 -16px 16px; padding: 12px 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
}
@media (prefers-reduced-transparency: reduce) {
  .finder { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
.search {
  position: relative; display: flex; align-items: center;
  height: 52px; border-radius: 16px;
  background: var(--card); box-shadow: var(--shadow), inset 0 0 0 1px var(--border);
  transition: box-shadow .2s var(--ease-out);
}
.search:focus-within { box-shadow: var(--shadow-hover), inset 0 0 0 2px var(--accent); }
.search > svg { position: absolute; left: 16px; width: 20px; height: 20px; color: var(--muted); pointer-events: none; }
.search input {
  flex: 1; min-width: 0; height: 100%;
  padding: 0 48px 0 46px; border: 0; background: none; outline: none;
  font: inherit; font-size: 16px; color: var(--text); letter-spacing: -.01em;
}
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd {
  position: absolute; right: 14px;
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px;
  display: grid; place-items: center;
  font-family: inherit; font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--surface);
}
.search .clear {
  position: absolute; right: 10px;
  width: 30px; height: 30px; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--surface); color: var(--muted);
  transition: transform .3s var(--spring);
}
.search .clear svg { width: 14px; height: 14px; }
.search .clear:active { transform: scale(.9); }
.search .clear[hidden], .search kbd[hidden] { display: none; }
@media (hover: none) { .search kbd { display: none; } }

.chips {
  display: flex; gap: 8px; margin-top: 12px; padding: 2px;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chips:empty { display: none; }
.chip {
  flex: none; height: 34px; padding: 0 14px; border: 0; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 600; letter-spacing: -.01em;
  background: var(--card); color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--border);
  transition: transform .4s var(--spring), background-color .2s var(--ease-out), color .2s var(--ease-out);
}
.chip .n { margin-left: 5px; font-weight: 500; opacity: .7; font-variant-numeric: tabular-nums; }
.chip:active { transform: scale(.95); transition-duration: .1s; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); box-shadow: none; }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 2px 14px; color: var(--muted); font-size: 14px;
}
.toolbar b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.sort {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 500; color: var(--text);
  height: 32px; padding: 0 30px 0 12px; border: 0; border-radius: 10px;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2398989d' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 9px center / 14px;
  box-shadow: inset 0 0 0 1px var(--border);
}
.sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 제품 카드 그리드 */
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
}
@media (max-width: 560px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.grid > li { animation: rise .5s var(--spring) backwards; animation-delay: calc(min(var(--i, 0), 10) * 30ms); }

.product {
  height: 100%; display: flex; flex-direction: column;
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); color: inherit; text-decoration: none;
  transition: transform .4s var(--spring), box-shadow .3s var(--ease-out);
  will-change: transform;
}
@media (hover: hover) {
  .product:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
  .product:hover .media img.photo { transform: scale(1.04); }
  .product:hover .go { color: var(--accent); transform: translateX(3px); }
}
.product:active { transform: scale(.97); transition-duration: .1s; transition-timing-function: ease-out; }
.product:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:root[data-theme="dark"] .product { box-shadow: inset 0 0 0 1px var(--border); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .product { box-shadow: inset 0 0 0 1px var(--border); } }

.media { position: relative; aspect-ratio: 1 / 1; background: var(--surface); overflow: hidden; }
.media img.photo { position: relative; width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .6s var(--ease-out); }
/* 타이핑 중 재렌더링은 짧은 페이드만 (스태거 없이) */
.grid.quiet > li { animation: pfade .18s linear backwards; animation-delay: 0s; }
@keyframes pfade { from { opacity: 0; } }
.media .ph {
  position: absolute; inset: 0; display: grid; place-items: center;
  background:
    radial-gradient(120% 90% at 30% 20%, color-mix(in srgb, var(--card) 70%, transparent), transparent 60%),
    var(--surface);
}
.media .ph img { width: 56px; height: 56px; border-radius: 14px; object-fit: contain; opacity: .9; }
.media .ph svg { width: 40px; height: 40px; color: var(--muted); opacity: .6; }
.media .tag {
  position: absolute; top: 10px; left: 10px;
  padding: 3px 9px; border-radius: 8px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .01em;
  color: #fff; background: rgba(0, 0, 0, .55);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}

.info { flex: 1; display: flex; flex-direction: column; gap: 6px; padding: 14px 16px 16px; min-width: 0; }
.store { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.store img { width: 16px; height: 16px; border-radius: 4px; object-fit: contain; }
.ptitle {
  margin: 0; font-size: 15.5px; font-weight: 600; line-height: 1.38; letter-spacing: -.015em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  overflow-wrap: anywhere;
}
.pdesc {
  margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pfoot { margin-top: auto; padding-top: 6px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.price { font-size: 17px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.price.none { font-size: 13.5px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.go { flex: none; color: var(--muted); font-size: 16px; transition: transform .4s var(--spring), color .2s var(--ease-out); }
mark { background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

@media (max-width: 560px) {
  .page-head h1 { font-size: 28px; }
  .info { padding: 12px 12px 14px; gap: 5px; }
  .ptitle { font-size: 14.5px; }
  .pdesc { display: none; }
  .price { font-size: 15.5px; }
}

/* 빈 상태 / 로딩 */
.grid > li.empty { grid-column: 1 / -1; padding: 64px 16px; text-align: center; color: var(--muted); animation: none; word-break: keep-all; }
.empty svg { width: 44px; height: 44px; opacity: .5; margin-bottom: 12px; }
.empty strong { display: block; color: var(--text); font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.empty button {
  margin-top: 16px; height: 36px; padding: 0 16px; border: 0; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 600; background: var(--accent); color: var(--accent-ink);
}
.skeleton .media, .skeleton .line { background: var(--surface); }
.skeleton .line { height: 12px; border-radius: 6px; }
.grid > li.skeleton { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

@media (prefers-reduced-motion: reduce) {
  .product, .go, .chip, .nav-btn, .media img.photo { transition: none; }
  .product:hover, .product:active, .nav-btn:hover, .nav-btn:active { transform: none; }
  .product:hover .media img.photo { transform: none; }
  .grid > li { animation: fade .2s linear backwards; }
  .grid > li.skeleton { animation: none; }
}
@media (prefers-contrast: more) { .product { outline: 1px solid var(--text); } }
