:root {
  --bg: #faf6f0;
  --bg-soft: #f2ebdf;
  --panel: #3d2b1f;
  --panel-deep: #2c1f16;
  --panel-hover: #4a3426;
  --text: #2c1f16;
  --text-on-panel: #f5f0eb;
  --muted: #7a6a5c;
  --muted-on-panel: #c9bdb0;
  --primary: #d4a574;
  --primary-hover: #e8c9a0;
  --border: #5c4033;
  --shadow: rgba(44, 31, 22, 0.12);
}

* { box-sizing: border-box; }

body {
  font-family: "Segoe UI", "Manrope", Arial, sans-serif;
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 15% 0%, #ffffff 0%, transparent 55%),
    radial-gradient(ellipse at 85% 20%, var(--bg-soft) 0%, transparent 50%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 40%, var(--bg-soft) 100%);
  color: var(--text);
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

/* Header */
.header {
  margin-top: 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--panel-deep), var(--panel));
  border: 1px solid var(--border);
  color: var(--text-on-panel);
  padding: 22px 28px;
  min-height: 88px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  box-shadow: 0 6px 20px var(--shadow);
  flex-wrap: wrap;
}

.logo {
  font-weight: 800;
  font-size: clamp(28px, 6vw, 42px);
  letter-spacing: 0.1em;
  color: var(--primary-hover);
  text-decoration: none;
  line-height: 1;
}

.nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
  font-size: 16px;
}

.nav a {
  color: var(--muted-on-panel);
  text-decoration: none;
  transition: color 0.2s;
}

.nav a:hover { color: var(--primary-hover); }

.cart-badge {
  display: inline-block;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--panel-deep);
  font-weight: 700;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  margin-left: 4px;
}

.user-badge {
  font-size: 14px;
  color: var(--primary-hover);
}

/* Layout */
.container {
  margin-top: 20px;
  margin-bottom: 24px;
}

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--panel-deep) 0%, var(--panel) 60%, var(--panel-hover) 100%);
  color: var(--text-on-panel);
  border-radius: 14px;
  padding: 20px 28px;
  margin-bottom: 22px;
  box-shadow: 0 6px 20px var(--shadow);
  border: 1px solid var(--border);
}

.hero h1 {
  margin: 4px 0 0;
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  color: var(--text-on-panel);
  line-height: 1.2;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  color: var(--primary-hover);
  margin: 0;
  font-weight: 700;
}

/* Headings */
h1, h2 {
  color: var(--panel-deep);
  margin-top: 0;
}

h2 { margin-bottom: 20px; font-size: 1.6rem; }

/* Grid & Cards */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  color: var(--text-on-panel);
  box-shadow: 0 4px 16px var(--shadow);
}

.product-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.product-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px var(--shadow);
}

.product-card h3 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.product-card h3 a {
  color: var(--text-on-panel);
  text-decoration: none;
}

.product-card h3 a:hover { color: var(--primary-hover); }

.product-image-wrap { display: block; }

.product-image,
.product-image-large {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-deep);
  display: block;
}

/* Высота обоих теперь рассчитывается от aspect-ratio: 3 / 4 */
.product-image-large {
  max-height: none;
}

.product-image-fallback {
  display: grid;
  place-items: center;
  font-size: 60px;
  color: var(--muted-on-panel);
  font-weight: 600;
  aspect-ratio: 3 / 4;
}

.product-content p {
  margin: 0 0 12px;
  color: var(--muted-on-panel);
  font-size: 14px;
  line-height: 1.5;
}

.product-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.price strong { color: var(--primary-hover); font-size: 18px; }

.muted { color: var(--muted); font-size: 13px; }
.card .muted, .product-page .muted { color: var(--muted-on-panel); }

.card-action {
  margin-top: auto;
  display: block;
  text-align: center;
}

/* Product page */
.product-page {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 1fr;
  gap: 32px;
  margin-top: 20px;
}

.product-page h1 {
  color: var(--text-on-panel);
  margin: 0 0 8px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  color: var(--text-on-panel);
  box-shadow: 0 4px 16px var(--shadow);
}

/* Buttons */
button,
.button-link {
  border: 0;
  background: var(--primary);
  color: var(--panel-deep);
  padding: 11px 18px;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  transition: background 0.2s;
  display: inline-block;
}

button:hover,
.button-link:hover { background: var(--primary-hover); }

button:disabled {
  background: #6b5c52;
  color: #a8a29e;
  cursor: not-allowed;
}

.back-link {
  display: inline-block;
  margin-top: 20px;
  color: var(--primary-hover);
  text-decoration: none;
  font-size: 15px;
}

.back-link:hover { text-decoration: underline; }

/* Footer */
.footer {
  margin-top: 60px;
  margin-bottom: 32px;
  padding: 24px 0;
  border-top: 1px solid #e8e2da;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.footer strong { color: var(--panel-deep); }
.footer p { margin: 4px 0; }

/* Responsive */
@media (max-width: 760px) {
  .product-page { grid-template-columns: 1fr; gap: 20px; }
  .hero { padding: 28px 22px; }
  .header { padding: 18px 20px; }
}.admin-link {
  color: var(--primary-hover) !important;
  font-weight: 700;
}

.nav form button:hover {
  color: var(--primary-hover) !important;
}
/* ——— Галерея товара ——— */
.product-gallery {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.product-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
}

.product-thumb {
  background: var(--panel-deep);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  transition: border-color 0.15s, transform 0.15s;
}

.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.product-thumb:hover {
  transform: translateY(-2px);
  border-color: var(--primary-hover);
}

.product-thumb.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}

@media (max-width: 760px) {
  .product-thumbs {
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  }
}
/* ——— Галерея товара ——— */
.product-gallery {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.product-main-wrap {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
}

.product-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  border: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 4px;
  z-index: 2;
  transition: background 0.15s, transform 0.15s;
}

.product-arrow:hover {
  background: rgba(0, 0, 0, 0.75);
  transform: translateY(-50%) scale(1.05);
}

.product-arrow.prev { left: 10px; }
.product-arrow.next { right: 10px; }

.product-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
}

.product-thumb {
  background: var(--panel-deep);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  transition: border-color 0.15s, transform 0.15s;
}

.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.product-thumb:hover {
  transform: translateY(-2px);
  border-color: var(--primary-hover);
}

.product-thumb.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}

/* ——— Лайтбокс (полноэкранный просмотр) ——— */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox.open {
  display: flex;
}

.lightbox img {
  max-width: 95vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 8px;
  cursor: default;
  user-select: none;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.lightbox-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 0;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  padding: 0 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.lightbox-arrow:hover {
  background: rgba(255, 255, 255, 0.3);
}

.lightbox-arrow.prev { left: 20px; }
.lightbox-arrow.next { right: 20px; }

/* ——— Мобильные ——— */
@media (max-width: 760px) {
  .product-thumbs {
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  }
  .product-arrow {
    width: 36px;
    height: 36px;
    font-size: 22px;
  }
  .lightbox-arrow {
    width: 44px;
    height: 44px;
    font-size: 26px;
  }
  .lightbox-arrow.prev { left: 8px; }
  .lightbox-arrow.next { right: 8px; }
  .lightbox-close {
    width: 36px;
    height: 36px;
    font-size: 24px;
    top: 12px;
    right: 12px;
  }
}
/* ——— Сетка для адреса ——— */
.address-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.address-grid .full { grid-column: 1 / -1; }
.address-grid .half { grid-column: span 1; }

@media (max-width: 500px) {
  .address-grid { grid-template-columns: 1fr; }
  .address-grid .full,
  .address-grid .half { grid-column: auto; }
}
/* ——— Кнопки мессенджеров ——— */
.messengers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}

.messenger-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  box-shadow: 0 2px 8px rgba(44, 31, 22, 0.15);
}

.messenger-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(44, 31, 22, 0.25);
  opacity: 0.95;
}

.messenger-icon {
  font-size: 16px;
  line-height: 1;
}

.mg-whatsapp { background: #25D366; }
.mg-telegram { background: #229ED9; }
.mg-max      { background: #8B5CF6; }
.mg-email    { background: #5c4033; }

/* На карточке товара — кнопки слева, не по центру */
.product-contact-hint {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.product-contact-hint .messengers {
  justify-content: flex-start;
  margin-top: 8px;
}

@media (max-width: 500px) {
  .messenger-btn {
    font-size: 13px;
    padding: 7px 12px;
  }
}