:root {
  --bg: #f3efe6;
  --paper: #fffdf8;
  --ink: #221e1a;
  --muted: #6f675e;
  --line: #e2d9cc;
  --accent: #0f6e56;
  --accent-dark: #0b5341;
  --danger: #9d2c2c;
  --warn: #8a5a12;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

a { color: inherit; }

button, input, textarea {
  font: inherit;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.04em;
}

.nav {
  display: flex;
  gap: 18px;
  align-items: center;
}

.nav a { text-decoration: none; }

.cart-count {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  text-align: center;
  font-size: 12px;
}

.wrap {
  width: min(1120px, calc(100% - 32px));
  margin: 28px auto 48px;
}

.narrow { width: min(480px, calc(100% - 32px)); }

.banner, .notice, .error, .ok {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
}

.banner, .notice {
  background: #fff6e4;
  color: var(--warn);
}

.error {
  background: #fdecec;
  color: var(--danger);
}

.ok {
  background: #e7f6f0;
  color: var(--accent-dark);
}

h1 { font-size: 32px; margin: 0 0 8px; }

.lead { color: var(--muted); margin-top: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.visual {
  height: 180px;
  display: flex;
  align-items: flex-end;
  padding: 14px;
  color: white;
  font-size: 22px;
  font-weight: 700;
}

.visual img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}

.card-body, .panel { padding: 16px; }

.card-body h2, .product-copy h1 {
  font-size: 20px;
  margin: 0 0 6px;
}

.tag, .price, .muted { color: var(--muted); }

.price { margin: 8px 0; }

.price strong, .total strong {
  color: var(--ink);
  font-size: 20px;
}

.card .btn, .row-actions { margin-top: auto; }

.btn, button {
  border: 0;
  background: var(--accent);
  color: white;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn.secondary, button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn:hover, button:hover { background: var(--accent-dark); }

button.secondary:hover { background: #f6f1e8; }

.product {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 28px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
}

.product .visual { height: 280px; border-radius: 12px; }

.qty {
  width: 72px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

label {
  display: block;
  margin-bottom: 12px;
}

input, textarea {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
}

.cart-item, .order {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.order { grid-template-columns: 1fr; align-items: start; }

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.site-footer {
  text-align: center;
  color: var(--muted);
  padding: 12px 16px 28px;
  font-size: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  padding: 10px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.toast.show { opacity: 1; }

.catalog {
  width: min(1280px, calc(100% - 48px));
  margin-top: 32px;
}

.catalog > h1 { font-size: clamp(2rem, 4vw, 3.25rem); }

.catalog-filters {
  display: grid;
  grid-template-columns: minmax(175px, 2fr) repeat(3, minmax(0, 1fr)) auto;
  gap: 16px;
  align-items: end;
  padding: 20px;
  margin-top: 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.catalog-filters label, .catalog-variant { margin: 0; font-size: .9rem; }
.catalog-filters input, .catalog-filters select, .catalog-variant select {
  width: 100%;
  min-height: 42px;
  margin-top: 6px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.catalog-filters .catalog-stock {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

.catalog-stock input { width: 1rem; height: 1rem; min-height: 0; margin: 0; }
.catalog-count { color: var(--muted); margin: 22px 0 14px; font-size: .9rem; }

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(10px, 1.5vw, 20px);
}

.catalog-card { display: flex; min-width: 0; }
.catalog-card-link {
  display: flex;
  width: 100%;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  text-decoration: none;
}

.catalog-card-link:is(:hover, :focus-visible) { border-color: #786594; }
.catalog-card-link:is(:hover, :focus-visible) h2 { text-decoration: underline; }
.catalog-media { display: grid; place-items: center; aspect-ratio: 1; background: #ece6df; }
.catalog-image { display: block; width: 100%; height: 100%; object-fit: contain; }
.catalog-media .catalog-image { mix-blend-mode: multiply; }
.catalog-copy { padding: clamp(10px, 1.7vw, 20px); }
.catalog-meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 10px; color: #654e7f; font-size: .85rem; }
.catalog-copy h2 { margin: 10px 0 6px; font-size: clamp(1rem, 1.6vw, 1.25rem); overflow-wrap: anywhere; }
.catalog-copy p { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.6; }

.catalog-back { display: inline-block; margin-bottom: 14px; }
.catalog-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
}

.catalog-detail-copy { padding: clamp(20px, 4vw, 56px); }
.catalog-detail-copy h1 { overflow-wrap: anywhere; }
.catalog-detail-price { font-size: 1.6rem; font-weight: 700; }
.catalog-variant { max-width: 340px; margin-bottom: 18px; }
.catalog-related { margin-top: 36px; }
.catalog-related h2 { font-size: 1.35rem; }

@media (max-width: 800px) {
  .grid { grid-template-columns: 1fr; }
  .product { grid-template-columns: 1fr; }
  .top { align-items: flex-start; flex-direction: column; }
  .cart-item { grid-template-columns: 1fr; }
  .catalog-filters { grid-template-columns: 1fr 1fr; }
  .catalog-filters label:first-child { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .catalog { width: calc(100% - 24px); margin-top: 14px; }
  .catalog-detail { grid-template-columns: 1fr; }
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .catalog-filters { padding: 12px; gap: 10px; }
}
