:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-soft: #f6f5f2;
  --text: #151515;
  --muted: #6a6a64;
  --border: #dedbd2;
  --border-strong: #c9c4b8;
  --dark: #161616;
  --dark-2: #242320;
  --accent: #b66a17;
  --accent-2: #8b4f10;
  --good: #2f7a52;
  --shadow: 0 18px 45px rgba(25, 23, 18, 0.12);
  --radius: 8px;
  --header-h: 74px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: var(--header-h);
  display: grid;
  grid-template-columns: minmax(230px, 300px) minmax(240px, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 12px clamp(18px, 3vw, 42px);
  color: #f8f7f3;
  background: var(--dark);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: block;
  width: 58px;
  height: 58px;
  overflow: hidden;
  background: #000;
  border-radius: 8px;
  flex: 0 0 auto;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 20px;
  line-height: 1.1;
}

.brand small {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.64);
  font-size: 13px;
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
}

.search svg,
.cart-toggle svg,
.icon-button svg,
.detail-back svg,
.gallery-nav svg,
.qty-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.search input {
  width: 100%;
  min-width: 0;
  color: #fff;
  background: transparent;
  border: 0;
  outline: 0;
}

.search input::placeholder {
  color: rgba(255, 255, 255, 0.48);
}

.cart-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 14px;
  color: #f8f7f3;
  background: var(--dark-2);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
}

.cart-toggle strong {
  display: grid;
  min-width: 24px;
  height: 24px;
  place-items: center;
  color: #161616;
  background: #f2b869;
  border-radius: 999px;
  font-size: 12px;
}

main {
  max-width: 1480px;
  margin: 0 auto;
  padding: 30px clamp(16px, 3vw, 42px) 70px;
}

.page-head {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
}

.page-head h1 {
  margin: 0;
  font-size: clamp(30px, 3vw, 44px);
  line-height: 1.05;
  font-weight: 760;
}

.page-head p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.toolbar {
  position: sticky;
  top: var(--header-h);
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 14px 0 18px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
}

.category-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.category-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  white-space: nowrap;
  padding: 0 14px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-weight: 720;
}

.category-tabs button span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.category-tabs button.is-active {
  color: #fff;
  background: var(--dark);
  border-color: var(--dark);
}

.category-tabs button.is-active span {
  color: rgba(255, 255, 255, 0.64);
}

.sort-control {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.sort-control select {
  min-height: 42px;
  padding: 0 34px 0 12px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
  align-items: stretch;
}

.product-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.product-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 16px 28px rgba(24, 23, 20, 0.09);
  transform: translateY(-2px);
}

.product-card__media {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  background: var(--panel-soft);
  border-bottom: 1px solid var(--border);
}

.product-card__media img,
.detail-main-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-count {
  position: absolute;
  right: 9px;
  bottom: 9px;
  min-width: 34px;
  padding: 4px 7px;
  color: #fff;
  background: rgba(21, 21, 21, 0.72);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 760;
  text-align: center;
}

.product-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  padding: 13px;
}

.product-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.product-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-title {
  min-height: 58px;
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.28;
  font-weight: 760;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.price-stack {
  margin-top: auto;
}

.price-label {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.price-main {
  display: block;
  color: var(--accent-2);
  font-size: 22px;
  line-height: 1.1;
  font-weight: 820;
}

.tier-list {
  display: grid;
  gap: 6px;
}

.tier-list--card {
  margin-top: -4px;
  padding: 8px;
  background: #f7f2e9;
  border: 1px solid #eadcc7;
  border-radius: 8px;
}

.tier-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
}

.tier-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.tier-row strong {
  flex: 0 0 auto;
  color: var(--good);
  font-size: 13px;
  font-weight: 820;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 2px;
}

.open-product,
.add-card {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 760;
}

.open-product {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
}

.add-card {
  min-width: 48px;
  color: #fff;
  background: var(--dark);
  border: 1px solid var(--dark);
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 28px;
}

.primary-action,
.secondary-action,
.text-action,
.detail-back,
.detail-add,
.copy-button {
  min-height: 44px;
  border-radius: 8px;
  font-weight: 760;
}

.primary-action,
.detail-add {
  color: #fff;
  background: var(--dark);
  border: 1px solid var(--dark);
}

.secondary-action,
.detail-back,
.copy-button {
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
}

.secondary-action {
  padding: 0 18px;
}

.text-action {
  color: var(--muted);
  background: transparent;
  border: 0;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 42px 18px;
  text-align: center;
  color: var(--muted);
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.detail-view {
  max-width: 1260px;
  margin: 0 auto;
}

.detail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.detail-back {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 13px;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(340px, 0.94fr);
  gap: clamp(22px, 4vw, 54px);
  align-items: start;
}

.gallery {
  min-width: 0;
}

.detail-main-image {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.gallery-nav {
  position: absolute;
  top: 50%;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #fff;
  background: rgba(21, 21, 21, 0.62);
  border: 0;
  border-radius: 999px;
  transform: translateY(-50%);
}

.gallery-nav.prev {
  left: 12px;
}

.gallery-nav.next {
  right: 12px;
}

.thumb-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 9px;
  margin-top: 12px;
}

.thumb-row button {
  overflow: hidden;
  aspect-ratio: 1 / 1;
  padding: 0;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.thumb-row button.is-active {
  border-color: var(--dark);
  box-shadow: 0 0 0 2px var(--dark) inset;
}

.thumb-row img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.detail-info {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  padding: 24px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(23, 20, 15, 0.08);
}

.detail-info h2 {
  margin: 0;
  font-size: clamp(25px, 3vw, 38px);
  line-height: 1.12;
  font-weight: 780;
}

.detail-subline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 20px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
}

.detail-price {
  padding: 18px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.detail-price strong {
  display: block;
  color: var(--accent-2);
  font-size: 34px;
  line-height: 1;
}

.tier-list--detail {
  margin-top: 14px;
  padding: 12px;
  background: #f7f2e9;
  border: 1px solid #eadcc7;
  border-radius: 8px;
}

.tier-list--detail .tier-row {
  font-size: 14px;
}

.tier-list--detail .tier-row strong {
  font-size: 15px;
}

.detail-buy {
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 10px;
  margin-top: 18px;
}

.qty-control {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  min-height: 48px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.qty-control button {
  display: grid;
  place-items: center;
  background: #fff;
  border: 0;
}

.qty-control input {
  min-width: 0;
  text-align: center;
  border: 0;
  border-inline: 1px solid var(--border);
  outline: 0;
  font-weight: 760;
}

.detail-note {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.cart-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.34);
}

.cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 60;
  display: flex;
  width: min(440px, 100vw);
  height: 100dvh;
  flex-direction: column;
  background: #fff;
  box-shadow: var(--shadow);
  transform: translateX(104%);
  transition: transform 180ms ease;
}

.cart-drawer.is-open {
  transform: translateX(0);
}

.cart-head,
.cart-footer {
  flex: 0 0 auto;
  padding: 18px;
  border-bottom: 1px solid var(--border);
}

.cart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cart-head h2 {
  margin: 0;
  font-size: 24px;
}

.cart-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.cart-items {
  flex: 1;
  overflow: auto;
  padding: 12px 18px;
}

.cart-row {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 11px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.cart-row img {
  width: 58px;
  height: 58px;
  object-fit: cover;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.cart-row h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.24;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cart-row p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.cart-tier {
  color: var(--good) !important;
  font-weight: 740;
}

.tier-list--cart {
  margin-top: 7px;
  padding: 7px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.tier-list--cart .tier-row {
  font-size: 11px;
}

.tier-list--cart .tier-row strong {
  font-size: 12px;
}

.cart-row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-top: 9px;
}

.mini-qty {
  display: inline-grid;
  grid-template-columns: 30px 34px 30px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.mini-qty button,
.remove-line {
  min-height: 32px;
  background: #fff;
  border: 0;
}

.mini-qty span {
  display: grid;
  min-height: 32px;
  place-items: center;
  border-inline: 1px solid var(--border);
  font-weight: 760;
}

.remove-line {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.cart-footer {
  border-top: 1px solid var(--border);
  border-bottom: 0;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
}

.cart-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.cart-total span {
  color: var(--muted);
  font-weight: 720;
}

.cart-total strong {
  font-size: 25px;
}

.cart-footer .primary-action,
.cart-footer .text-action {
  width: 100%;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 80;
  max-width: calc(100vw - 32px);
  padding: 12px 14px;
  color: #fff;
  background: var(--dark);
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 900px) {
  :root {
    --header-h: 132px;
  }

  .site-header {
    grid-template-columns: 1fr auto;
  }

  .search {
    grid-column: 1 / -1;
    order: 3;
  }

  .page-head,
  .toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .sort-control {
    justify-content: space-between;
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .detail-info {
    position: static;
    padding: 18px;
  }
}

@media (max-width: 560px) {
  main {
    padding-inline: 12px;
  }

  .site-header {
    padding-inline: 12px;
    gap: 10px;
  }

  .brand small,
  .cart-toggle span {
    display: none;
  }

  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .product-card__body {
    padding: 10px;
  }

  .product-title {
    min-height: 54px;
    font-size: 14px;
  }

  .price-main {
    font-size: 19px;
  }

  .card-actions {
    grid-template-columns: 1fr;
  }

  .add-card {
    min-width: 100%;
  }

  .detail-buy {
    grid-template-columns: 1fr;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
