:root {
  --bg: #f3efe6;
  --bg-deep: #e7e0d2;
  --ink: #1c1a16;
  --muted: #6b6458;
  --line: #d4cdc0;
  --surface: #faf8f3;
  --accent: #2f5d4a;
  --accent-ink: #f7f4ec;
  --ok: #2f6b45;
  --warn: #9a6b1f;
  --err: #8f3a32;
  --transit: #3d5a80;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(40, 32, 18, 0.08);
  --font: "Manrope", "Segoe UI", system-ui, sans-serif;
  --display: "Source Serif 4", Georgia, serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 0% -10%, #ddd4c2 0%, transparent 55%),
    radial-gradient(700px 380px at 100% 0%, #d5e0d4 0%, transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
}

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

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 48px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--bg) 88%, white 12%);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--display);
  font-size: 1rem;
}

.brand-name {
  font-family: var(--display);
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}

.search input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  color: var(--ink);
}

.search input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 1px;
}

.cart-link {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.cart-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.main { padding: 18px 14px 0; }

.hero-band { margin-bottom: 20px; }

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.page-title {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 1.85rem;
  line-height: 1.15;
  font-weight: 600;
}

.page-lead {
  margin: 0 0 8px;
  color: var(--muted);
  line-height: 1.45;
}

.crumbs {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}

.crumbs a { text-decoration: underline; text-underline-offset: 2px; }

.section { margin: 22px 0; }

.section-title {
  margin: 0 0 12px;
  font-size: 1.05rem;
  font-weight: 700;
}

.section-title.sm { font-size: 0.95rem; margin-top: 18px; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 600;
  font-size: 14px;
  transition: transform 0.15s ease, background 0.15s ease;
}

.chip:active { transform: scale(0.97); }

.h-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.h-scroll .mini-card {
  flex: 0 0 168px;
  scroll-snap-align: start;
}

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

.mini-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  animation: rise 0.35s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.mini-card-media {
  display: block;
  aspect-ratio: 1;
  background: #ebe4d7;
  overflow: hidden;
}

.mini-card-media img,
.gallery-main img,
.cart-item-media img,
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.media-placeholder {
  width: 100%;
  height: 100%;
  min-height: 120px;
  background:
    linear-gradient(135deg, #e8e0d2 0%, #d9d1c2 50%, #ece5d8 100%);
}

.media-placeholder.sm { min-height: 72px; aspect-ratio: 1; }

.mini-card-body {
  padding: 10px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.mini-card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mini-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
}

.price {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.price.xl { font-size: 1.55rem; }

.avail {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.avail-in_stock { color: var(--ok); }
.avail-in_transit { color: var(--transit); }
.avail-on_order { color: var(--warn); }

.btn-add,
.btn,
button.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  font: inherit;
  font-weight: 650;
  font-size: 14px;
  cursor: pointer;
  text-align: center;
  background: var(--accent);
  color: var(--accent-ink);
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.btn-add { width: 100%; margin-top: auto; padding: 9px 10px; font-size: 13px; }

.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost,
.btn-add.ghost,
button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn:disabled,
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn:active:not(:disabled),
.btn-add:active { transform: scale(0.98); }

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0 16px;
}

.filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.filter select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font: inherit;
  background: var(--surface);
  color: var(--ink);
}

.empty {
  color: var(--muted);
  margin: 12px 0;
}

.product { display: grid; gap: 16px; }

.gallery-main {
  aspect-ratio: 1;
  border-radius: calc(var(--radius) + 2px);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #ebe4d7;
}

.gallery-thumbs {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  overflow-x: auto;
}

.thumb {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  padding: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  background: #ebe4d7;
  cursor: pointer;
}

.thumb.is-active { border-color: var(--accent); }

.product-price-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 8px 0 14px;
}

.prose, .specs {
  color: var(--ink);
  line-height: 1.5;
  font-size: 15px;
}

.product-actions { margin-top: 18px; }
.product-actions .btn { width: 100%; padding: 14px; font-size: 15px; }

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.row .btn { flex: 1 1 140px; }

.modal {
  border: 0;
  padding: 0;
  border-radius: 18px;
  background: transparent;
  max-width: 420px;
  width: calc(100% - 28px);
}

.modal::backdrop {
  background: rgba(28, 26, 22, 0.45);
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  display: grid;
  gap: 10px;
}

.modal-card h2 { margin: 0; font-family: var(--display); }

.modal-card label {
  display: grid;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.modal-card input,
.modal-card textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

.form-msg { color: var(--ok); font-size: 14px; margin: 0; }

.cart-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.cart-item {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 10px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  align-items: start;
}

.cart-item-media {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  background: #ebe4d7;
}

.qty-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.qty-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 16px;
  cursor: pointer;
}

.qty-val {
  min-width: 1.5ch;
  text-align: center;
  font-weight: 700;
}

.link-danger {
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--err);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}

.cart-item-total {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cart-footer {
  position: sticky;
  bottom: 0;
  margin-top: 18px;
  padding: 14px 0 8px;
  background: linear-gradient(180deg, transparent, var(--bg-deep) 28%);
  display: grid;
  gap: 10px;
}

.cart-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 1.05rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: #f7f4ec;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}

.toast.is-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.badge {
  display: inline-block;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  margin-bottom: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.meta {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.log {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  background: #1c1a16;
  border: 1px solid #333;
  color: #cfc7b8;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 48px;
}

.warn-box {
  border-color: #c9a45a;
  background: #f6ebcf;
  color: #6a4d12;
  font-size: 14px;
  line-height: 1.45;
}

.status {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 8px 0;
}

.status.paid { color: var(--ok); }
.status.pending { color: var(--warn); }
.status.failed,
.status.canceled { color: var(--err); }
