:root {
  --brand: #f5821f;
  --brand-dark: #d96f12;
  --ink: #17150f;
  --muted: #6f6a60;
  --line: #e8e4dc;
  --panel: #f7f4ef;
  --bg: #fff;
  --radius: 12px;
  --max: 1200px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

.container { max-width: var(--max); margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 88px; gap: 20px; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo img { height: 76px; width: auto; }
nav.main-nav { display: flex; align-items: center; gap: 22px; font-weight: 500; font-size: 15px; }
nav.main-nav a:hover { color: var(--brand-dark); }
.cart-link { position: relative; display: inline-flex; align-items: center; padding: 8px; margin: -8px; }
.cart-link svg { width: 28px; height: 28px; }
.cart-count {
  position: absolute; top: 0; right: -1px;
  background: var(--brand); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1;
  min-width: 17px; height: 17px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* Hero */
.hero { padding: 44px 0 8px; }
.hero h1 { font-size: clamp(28px, 4vw, 42px); margin: 0 0 8px; letter-spacing: -0.02em; }
.hero p { color: var(--muted); margin: 0; max-width: 60ch; }

/* Header search */
.header-actions { display: flex; align-items: center; gap: 14px; }
.header-search { width: 0; overflow: hidden; transition: width 0.25s ease; }
.header-search.open { width: min(300px, 55vw); }
.header-search .search {
  width: 100%; padding: 10px 14px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--panel);
  outline: none;
}
.header-search .search:focus { border-color: var(--brand); background: #fff; }
.search-toggle { border: 0; background: none; padding: 8px; margin: -8px 0; cursor: pointer; color: var(--ink); display: inline-flex; }
.search-toggle svg { width: 28px; height: 28px; }
.search-toggle:hover { color: var(--brand-dark); }

/* Grid */
.grid {
  display: grid; gap: 26px 20px; padding: 20px 0 60px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.card { display: block; }
.card-img { position: relative; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.card-img img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.35s ease; }
.card:hover .card-img img { transform: scale(1.04); }
.badge {
  position: absolute; top: 10px; left: 10px;
  background: rgba(23, 21, 15, 0.85); color: #fff;
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
}
.card h3 { font-size: 15px; font-weight: 500; margin: 12px 0 4px; line-height: 1.35; }
.card-price { font-weight: 700; font-size: 15px; }
.empty { padding: 60px 0; color: var(--muted); text-align: center; grid-column: 1 / -1; }

/* Pagination */
.pagination { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; padding: 4px 0 64px; }
.page-link {
  min-width: 40px; height: 40px; padding: 0 12px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 10px; font-weight: 500;
}
.page-link:hover { border-color: var(--brand); }
.page-link.current { background: var(--ink); color: #fff; border-color: var(--ink); }
.grid[hidden], .pagination[hidden] { display: none; }

/* Product page */
.crumbs { padding: 20px 0 4px; font-size: 13px; color: var(--muted); }
.crumbs a:hover { color: var(--brand-dark); }
.product-layout { display: grid; grid-template-columns: 1.1fr 1fr; gap: 48px; padding: 16px 0 40px; align-items: start; }
.gallery-main { width: 100%; border-radius: var(--radius); background: var(--panel); aspect-ratio: 1; object-fit: contain; }
.gallery { position: relative; }
.gallery-nav {
  position: absolute; top: calc(50% - 30px); transform: translateY(-50%);
  width: 44px; height: 44px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 50%;
  background: rgba(255, 255, 255, 0.92); color: var(--ink); cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}
.gallery-nav svg { width: 22px; height: 22px; }
.gallery-nav:hover { background: #fff; border-color: var(--brand); }
.gallery-nav.prev { left: 12px; }
.gallery-nav.next { right: 12px; }
.thumbs { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.thumbs button { padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: var(--panel); cursor: pointer; width: 64px; height: 64px; }
.thumbs button.active { border-color: var(--brand); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.product-info h1 { font-size: clamp(22px, 3vw, 30px); margin: 0 0 10px; letter-spacing: -0.01em; }
.price { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.stock { font-size: 14px; color: var(--muted); margin: 0 0 18px; }
.stock.out { color: #b3261e; }
.variants { display: grid; gap: 14px; margin-bottom: 20px; }
.variants label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.variants select { padding: 11px 12px; font-size: 15px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-weight: 400; color: var(--ink); }
.buy-row { display: flex; gap: 12px; align-items: stretch; }
.qty { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.qty button { width: 42px; border: 0; background: #fff; font-size: 18px; cursor: pointer; }
.qty button:hover { background: var(--panel); }
.qty input { width: 46px; border: 0; text-align: center; font-size: 15px; -moz-appearance: textfield; appearance: textfield; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.btn-primary {
  flex: 1; border: 0; border-radius: 10px; padding: 14px 22px;
  background: var(--brand); color: #fff; font-size: 16px; font-weight: 600; cursor: pointer;
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { background: #d9d4cb; cursor: not-allowed; }
.ship-note { font-size: 13px; color: var(--muted); margin: 14px 0 0; }
.description { max-width: 72ch; padding: 12px 0 64px; }
.description h2 { font-size: 20px; margin: 0 0 12px; }
.description p { margin: 0 0 14px; }

/* Cart */
.cart-page { padding: 32px 0 64px; }
.cart-page h1 { margin: 0 0 24px; }
.cart-list { display: grid; gap: 0; border-top: 1px solid var(--line); }
.cart-item { display: grid; grid-template-columns: 84px 1fr auto; gap: 18px; align-items: center; padding: 18px 0; border-bottom: 1px solid var(--line); }
.cart-item img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; background: var(--panel); }
.cart-item h3 { font-size: 15px; margin: 0 0 4px; font-weight: 600; }
.cart-item .variant { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.cart-item .qty { width: max-content; }
.cart-right { text-align: right; display: grid; gap: 8px; justify-items: end; }
.cart-right .line-price { font-weight: 700; }
.link-btn { border: 0; background: none; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 13px; padding: 0; }
.link-btn:hover { color: var(--ink); }
.cart-summary { display: flex; justify-content: space-between; align-items: center; padding: 24px 0; gap: 20px; flex-wrap: wrap; }
.cart-total { font-size: 20px; font-weight: 700; }
.cart-note { color: var(--muted); font-size: 14px; }

/* Simple pages */
.page { max-width: 72ch; padding: 40px 0 64px; }
.page h1 { margin: 0 0 16px; }
.page p { margin: 0 0 16px; }
.contact-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 24px; }
.contact-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; background: var(--panel); }
.contact-card h3 { margin: 0 0 6px; font-size: 16px; }
.contact-card a { color: var(--brand-dark); font-weight: 600; }

/* Success / cancel */
.status { max-width: 56ch; padding: 64px 0 96px; text-align: center; margin: 0 auto; }
.status h1 { margin: 0 0 12px; }
.status p { color: var(--muted); }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding: 32px 0 40px; color: var(--muted); font-size: 14px; }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: center; }
.footer-inner a:hover { color: var(--brand-dark); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all 0.25s ease; z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Page transitions */
@view-transition { navigation: auto; }

.grid .card { animation: card-in 0.35s ease-out both; animation-delay: calc(var(--i, 0) * 18ms); }
@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .grid .card { animation: none !important; }
  html { scroll-behavior: auto; }
}

@media (max-width: 760px) {
  .product-layout { grid-template-columns: 1fr; gap: 26px; }
  .header-inner { height: 72px; }
  .logo img { height: 48px; }
  .cart-item { grid-template-columns: 64px 1fr; }
  .cart-item img { width: 64px; height: 64px; }
  .cart-right { grid-column: 2; justify-items: start; text-align: left; }
}
