:root {
  --text: #333;
  --muted: #777;
  --line: #e6e6e6;
  --photo-bg: #f4f2ee;
  --gutter: clamp(16px, 5vw, 100px);
  --font: 'Gowun Batang', 'Nanum Myeongjo', 'Batang', Georgia, serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: #fff;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  border-top: 4px solid var(--line);
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }

/* ---------- Header & navigation ---------- */

.site-header {
  padding: 22px var(--gutter) 0;
  text-align: center;
}

.brand {
  display: inline-block;
  font-size: clamp(20px, 4vw, 28px);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text);
}

.nav {
  display: flex;
  gap: 8px 44px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 14px auto 0;
  padding: 0;
  list-style: none;
  max-width: 1100px;
}

.nav a {
  display: block;
  padding: 6px 0;
  color: #666;
  letter-spacing: 0.08em;
  border-bottom: 1px solid transparent;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); border-bottom-color: currentColor; }

.page-title {
  margin: 18px 0 22px;
  text-align: center;
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: #555;
}

/* ---------- Product grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 26px 10px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--gutter) 80px;
}

.card { display: block; text-align: center; }

.card-photo {
  position: relative;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: var(--photo-bg);
}
.card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .5s ease, opacity .3s;
}
.card:hover .card-photo img { transform: scale(1.03); }

.card-plus {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
  font: 20px/1 system-ui, sans-serif;
}

.card-title {
  margin: 18px 0 0;
  font-size: 14px;
  letter-spacing: 0.06em;
}
.card-meta {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.status { padding: 60px 16px; text-align: center; color: var(--muted); }

/* ---------- Product page ---------- */

.product {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 48px;
  max-width: 1300px;
  margin: 24px auto 0;
  padding: 0 var(--gutter) 80px;
}

.back {
  display: inline-block;
  margin-bottom: 14px;
  font-size: 14px;
  color: var(--muted);
}
.back:hover { color: var(--text); }

.gallery { position: relative; min-width: 0; }

.slides {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  background: var(--photo-bg);
}
.slides::-webkit-scrollbar { display: none; }

.slide {
  flex: 0 0 100%;
  aspect-ratio: 1;
  scroll-snap-align: center;
}
.slide img { width: 100%; height: 100%; object-fit: contain; }

.arrow {
  position: absolute;
  top: calc(50% - 60px);
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .15);
  font: 22px/1 system-ui, sans-serif;
  cursor: pointer;
}
.arrow:disabled { opacity: .3; cursor: default; }
.arrow.prev { left: 12px; }
.arrow.next { right: 12px; }

.counter {
  margin: 8px 0 0;
  font-size: 13px;
  text-align: center;
  color: var(--muted);
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.thumbs button {
  padding: 0;
  border: 1px solid transparent;
  background: var(--photo-bg);
  aspect-ratio: 1;
  cursor: pointer;
  opacity: .65;
  transition: opacity .15s, border-color .15s;
}
.thumbs button:hover { opacity: 1; }
.thumbs button[aria-current="true"] { opacity: 1; border-color: var(--text); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }

.info { position: sticky; top: 24px; align-self: start; padding-top: 34px; }
.info h1 {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 400;
  letter-spacing: 0.06em;
}
.info .category { margin: 0 0 24px; color: var(--muted); font-size: 14px; }
.info .description { margin: 0; line-height: 1.9; color: #555; white-space: pre-line; }

/* ---------- Scroll-to-top ---------- */

.to-top {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #eee;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
  font: 20px/1 system-ui, sans-serif;
  cursor: pointer;
}

[hidden] { display: none !important; }

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .nav { gap: 8px 28px; }
}

@media (max-width: 760px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 8px; }
  .card-title { margin-top: 10px; font-size: 13px; }
  .card-plus { width: 26px; height: 26px; font-size: 17px; right: 8px; bottom: 8px; }

  /* Category menu becomes a single swipeable row. */
  .nav {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    gap: 22px;
    margin-inline: calc(-1 * var(--gutter));
    padding-inline: var(--gutter);
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .page-title { font-size: 19px; margin: 14px 0 18px; }

  .product { grid-template-columns: 1fr; gap: 20px; margin-top: 12px; }
  .gallery { margin-inline: calc(-1 * var(--gutter)); }
  .slide { aspect-ratio: 4 / 5; }
  .counter, .thumbs { padding-inline: var(--gutter); }
  .thumbs {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 64px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .thumbs::-webkit-scrollbar { display: none; }
  .arrow { display: none; }
  .info { position: static; padding-top: 0; }
  .info h1 { font-size: 22px; }
}
