:root {
  --bg: #ecf4ef;
  --surface: #ffffff;
  --ink: #102218;
  --muted: #4a6056;
  --brand: #0d3b2c;
  --brand2: #1a6b4f;
  --gold: #c9a227;
  --gold-dim: rgba(201, 162, 39, 0.25);
  --radius: 16px;
  --shadow: 0 12px 40px rgba(13, 59, 44, 0.12);
  --font: "Vazirmatn", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  background: linear-gradient(180deg, var(--bg) 0%, #dfece4 55%, #cddfd3 100%);
  color: var(--ink);
  padding-bottom: calc(104px + env(safe-area-inset-bottom));
}

.handoff {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
}

.handoff[data-open="1"] {
  display: block;
}

.handoff__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
}

.handoff__panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100% - 28px));
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(13, 59, 44, 0.08);
  padding: 16px 16px 14px;
}

.handoff__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.handoff__text {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.8;
  font-size: 0.92rem;
}

.handoff__actions {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.handoff__hint {
  margin: 12px 0 0;
  color: rgba(16, 34, 24, 0.7);
  font-size: 0.84rem;
  line-height: 1.7;
}

.handoff__close {
  margin-top: 10px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  cursor: pointer;
  padding: 10px 12px;
}

.hdr {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand2) 100%);
  color: #f7fdf9;
  padding: 14px 16px calc(14px + env(safe-area-inset-top));
  padding-top: calc(14px + env(safe-area-inset-top));
  box-shadow: var(--shadow);
}

.hdr__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 720px;
  margin: 0 auto;
}

.hdr__logo {
  border-radius: 14px;
  background: var(--surface);
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.hdr__logo.hdr__logo--hidden {
  display: none;
}

.hdr__titles {
  min-width: 0;
}

.hdr__name {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hdr__tag {
  margin: 4px 0 0;
  font-size: 0.8rem;
  opacity: 0.88;
}

.catbar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 16px;
  scrollbar-width: none;
  max-width: 720px;
  margin: 0 auto;
}

.catbar::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  border: 1px solid rgba(13, 59, 44, 0.15);
  background: var(--surface);
  color: var(--brand);
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(13, 59, 44, 0.06);
}

.chip[data-active="1"] {
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  color: #fff;
  border-color: transparent;
}

.main {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 14px 20px;
}

.toolbar {
  margin-bottom: 14px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: var(--shadow);
}

.search input {
  flex: 1;
  border: none;
  font-family: var(--font);
  font-size: 0.95rem;
  background: transparent;
  outline: none;
}

.search__icon {
  opacity: 0.55;
}

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

@media (min-width: 560px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  border: 1px solid rgba(13, 59, 44, 0.06);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.card:active {
  transform: scale(0.98);
}

.card__ph {
  height: 118px;
  background: radial-gradient(circle at 30% 20%, var(--gold-dim), transparent 55%),
    linear-gradient(160deg, #e8efe9, #cfdad2);
}

.card__media {
  height: 118px;
  overflow: hidden;
  background: radial-gradient(circle at 30% 20%, var(--gold-dim), transparent 55%),
    linear-gradient(160deg, #e8efe9, #cfdad2);
}

.card__img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.card__body {
  padding: 11px 12px 12px;
  flex: 1;
}

.card__title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 8px;
}

.card__price {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--brand2);
}

.badge-mini {
  min-width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--gold);
  color: #252000;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty {
  text-align: center;
  color: var(--muted);
  margin: 48px 0;
  font-size: 0.95rem;
}

.cartdock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: rgba(247, 252, 249, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(13, 59, 44, 0.1);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  box-shadow: 0 -16px 40px rgba(13, 59, 44, 0.1);
}

.cartdock__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 720px;
  margin: 0 auto;
}

.cartdock__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.82rem;
  color: var(--muted);
}

.cartdock__qty {
  font-weight: 600;
  color: var(--ink);
}

.cartdock__sum {
  font-variant-numeric: tabular-nums;
}

.btn {
  font-family: var(--font);
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  padding: 12px 18px;
  font-size: 0.92rem;
}

.btn--primary {
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  color: #fff;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(13, 59, 44, 0.28);
}

.btn--primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--block {
  width: 100%;
  margin-top: 10px;
  padding: 14px;
  background: var(--brand);
  color: #fff;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sheet[data-open="1"] {
  pointer-events: auto;
  opacity: 1;
}

.sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 30, 22, 0.45);
}

.sheet__panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 16px 18px calc(22px + env(safe-area-inset-bottom));
  max-height: 78dvh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.24s cubic-bezier(0.32, 0.72, 0.25, 1);
  box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.18);
}

.sheet[data-open="1"] .sheet__panel {
  transform: translateY(0);
}

.sheet__close {
  position: absolute;
  left: 12px;
  top: 10px;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  font-size: 1.65rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.sheet__media {
  margin: 42px -2px 8px -2px;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(160deg, #e8efe9, #cfdad2);
}

.sheet__img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  display: block;
}

.sheet__title {
  margin: 8px 0 4px;
  font-size: 1.05rem;
  padding-left: 40px;
}

.sheet__unit {
  margin: 0 0 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.sheet__desc {
  margin: 0 0 14px;
  font-size: 0.875rem;
  line-height: 1.65;
  color: #354a41;
}

.sheet__price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.sheet__price {
  font-weight: 700;
  color: var(--brand);
  font-size: 1.05rem;
}

.qtyctl {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border-radius: 12px;
  padding: 4px;
}

.qtyctl button {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: var(--surface);
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--brand);
  font-family: inherit;
}

.qtyctl span {
  min-width: 28px;
  text-align: center;
  font-weight: 700;
}

.toast {
  position: fixed;
  bottom: calc(118px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  z-index: 70;
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.875rem;
  max-width: min(440px, 92vw);
  transition: transform 0.22s ease;
}

.toast[data-show="1"] {
  transform: translateX(-50%) translateY(0);
}
