:root {
  --bg: var(--tg-theme-bg-color, #faf8f5);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f1ece3);
  --text: var(--tg-theme-text-color, #241f1a);
  --hint: var(--tg-theme-hint-color, #928879);
  --link: var(--tg-theme-link-color, #a67c3d);
  --button: var(--tg-theme-button-color, #241f1a);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --accent: #a67c3d;
  --danger: #b3392c;
  --radius: 14px;
  --font-serif: "Playfair Display", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { padding-bottom: 150px; }

body.has-bg {
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}

#dev-banner {
  background: #fff3cd;
  color: #7a5b00;
  font-size: 12px;
  text-align: center;
  padding: 6px 10px;
}

.hidden { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg);
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.brand {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  position: relative;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 6px;
  color: var(--text);
}

.badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

#app { padding: 12px 16px 24px; }

.view-title {
  font-family: var(--font-serif);
  font-size: 23px;
  font-weight: 700;
  margin: 4px 0 14px;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 14px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-chip {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--secondary-bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

.tab-chip.active {
  background: var(--button);
  color: var(--button-text);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.card {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.card img, .card video {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
  background: #ddd;
}

.card-body { padding: 10px 10px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }

.card-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

.price-row { display: flex; align-items: baseline; gap: 6px; margin-top: auto; }

.price { font-weight: 800; font-size: 14px; }
.old-price { font-size: 12px; color: var(--hint); text-decoration: line-through; }

.add-btn {
  margin-top: 8px;
  border: none;
  border-radius: 10px;
  padding: 8px;
  background: var(--button);
  color: var(--button-text);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.back-link {
  background: none;
  border: none;
  color: var(--link);
  font-size: 14px;
  font-weight: 600;
  padding: 6px 0 14px;
  cursor: pointer;
}

#product-detail img, #product-detail video {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: #ddd;
}

.product-gallery {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
}
.gallery-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.gallery-track::-webkit-scrollbar { display: none; }
.gallery-item {
  flex: 0 0 100%;
  scroll-snap-align: start;
  min-width: 0;
}
.gallery-dots {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
  pointer-events: none;
}
.gallery-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  box-shadow: 0 0 2px rgba(0,0,0,0.3);
}
.gallery-dot.active { background: #fff; }

.product-title { font-size: 20px; font-weight: 800; margin: 14px 0 4px; }
.product-price-row { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.product-price { font-size: 20px; font-weight: 800; }
.product-desc { color: var(--text); line-height: 1.5; font-size: 14px; margin-bottom: 16px; white-space: pre-line; }

.size-label { font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.size-options { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.size-chip {
  border: 1.5px solid var(--secondary-bg);
  background: var(--secondary-bg);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.size-chip.active { border-color: var(--accent); background: var(--bg); }

.qty-row { display: flex; align-items: center; gap: 14px; margin-bottom: 90px; }
.qty-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--secondary-bg);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}
.qty-value { font-size: 16px; font-weight: 700; min-width: 20px; text-align: center; }

.cart-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.cart-item img, .cart-item video { width: 64px; height: 80px; object-fit: cover; border-radius: 10px; background: #ddd; }
.cart-item-info { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.cart-item-name { font-size: 13px; font-weight: 700; }
.cart-item-meta { font-size: 12px; color: var(--hint); }
.cart-item-controls { display: flex; align-items: center; gap: 10px; margin-top: auto; }
.cart-item-price { font-weight: 800; font-size: 13px; margin-left: auto; }
.remove-btn { background: none; border: none; color: var(--danger); font-size: 12px; font-weight: 700; cursor: pointer; padding: 0; }

.empty-state { color: var(--hint); font-size: 14px; padding: 40px 0; text-align: center; }

.summary { margin-top: 14px; padding-top: 10px; border-top: 1px solid rgba(0,0,0,0.08); margin-bottom: 100px; }
.summary-row { display: flex; justify-content: space-between; font-size: 16px; font-weight: 800; }

#checkout-form { display: flex; flex-direction: column; gap: 14px; }
#checkout-form label { font-size: 13px; font-weight: 700; display: flex; flex-direction: column; gap: 6px; }
#checkout-form input,
#checkout-form textarea {
  font: inherit;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid rgba(0,0,0,0.1);
  background: var(--secondary-bg);
  color: var(--text);
  resize: vertical;
}
#checkout-form textarea { min-height: 60px; }

.fineprint { font-size: 12px; color: var(--hint); line-height: 1.5; margin-top: 12px; }

.success-box { text-align: center; padding: 60px 10px 20px; }
.success-icon { font-size: 46px; margin-bottom: 10px; }
.success-box h2 { font-size: 20px; margin: 0 0 10px; }
.success-box p { color: var(--hint); font-size: 14px; line-height: 1.5; margin-bottom: 24px; }

.fixed-bottom {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 10;
}

.fallback-btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 14px;
  background: var(--button);
  color: var(--button-text);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.fallback-btn:disabled { opacity: 0.5; cursor: default; }

/* ---------- админ-панель ---------- */

.admin-section { margin-bottom: 22px; }
.admin-section-title { font-size: 14px; font-weight: 800; margin-bottom: 10px; }

.admin-secondary-btn {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--secondary-bg);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.admin-danger-btn { color: var(--danger); }

.admin-add-btn {
  width: 100%;
  border: 1.5px dashed var(--hint);
  border-radius: 10px;
  padding: 12px;
  background: none;
  color: var(--hint);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 14px;
}

.order-card {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.order-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.order-card-id { font-weight: 800; font-size: 14px; }
.order-card-date { font-size: 11px; color: var(--hint); }

.order-card-items { font-size: 12px; color: var(--text); margin-bottom: 8px; line-height: 1.5; }
.order-card-customer { font-size: 12px; color: var(--text); line-height: 1.6; margin-bottom: 10px; }
.order-card-customer a { color: var(--link); text-decoration: none; }

.order-card-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.order-card-total { font-weight: 800; font-size: 14px; }

.status-select {
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1.5px solid rgba(0,0,0,0.1);
  background: var(--bg);
  color: var(--text);
}

.admin-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.admin-row img, .admin-row video {
  width: 48px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  background: #ddd;
  flex-shrink: 0;
}

.admin-row-info { flex: 1; min-width: 0; }
.admin-row-name { font-size: 13px; font-weight: 700; }
.admin-row-meta { font-size: 12px; color: var(--hint); }

.admin-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.icon-action-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
}

.admin-form label {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.admin-form input,
.admin-form select,
.admin-form textarea {
  font: inherit;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid rgba(0,0,0,0.1);
  background: var(--secondary-bg);
  color: var(--text);
  resize: vertical;
}
.admin-form textarea { min-height: 70px; }
.admin-form-actions { display: flex; gap: 10px; margin-top: 6px; margin-bottom: 90px; }
.admin-form-actions .fallback-btn,
.admin-form-actions .admin-secondary-btn { flex: 1; position: static; }

.image-upload-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.image-thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--secondary-bg);
}
.image-thumb img, .image-thumb video { width: 100%; height: 100%; object-fit: cover; }
.image-thumb .remove-img {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}
.upload-tile {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  border: 1.5px dashed var(--hint);
  background: none;
  color: var(--hint);
  font-size: 22px;
  cursor: pointer;
}

.admin-empty { color: var(--hint); font-size: 13px; padding: 20px 0; text-align: center; }
.admin-error { color: var(--danger); font-size: 13px; padding: 10px 0; }

.admin-hint { font-size: 12px; color: var(--hint); line-height: 1.5; margin-bottom: 14px; }

.bg-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--secondary-bg);
  margin-bottom: 14px;
}
.bg-preview img { width: 100%; height: 100%; object-fit: cover; }
.bg-preview-empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--hint);
  font-size: 13px;
}

/* ---------- главная ---------- */

.hero {
  margin: -12px -16px 0;
  background-color: #12141c;
  color: #fff;
}
.hero-logo {
  height: 210px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: #12141c;
}
.hero-content { padding: 16px 18px 20px; max-width: 280px; background-color: #171a24; }
.hero-subtitle {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1.6px;
  opacity: 0.92;
  margin-bottom: 8px;
}
.hero-tagline {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.8px;
  line-height: 1.5;
  opacity: 0.85;
  margin-bottom: 12px;
}
.hero-cta {
  border: none;
  border-radius: 999px;
  padding: 9px 16px;
  background: #e9c98f;
  color: #2b2318;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
}

.home-section { margin: 24px 0; }

.category-tiles {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.category-tiles::-webkit-scrollbar { display: none; }
.category-tile {
  flex: 0 0 auto;
  width: 108px;
  border: none;
  background: var(--secondary-bg);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  text-align: left;
}
.category-tile img { width: 100%; aspect-ratio: 1/1; object-fit: cover; display: block; }
.category-tile-label {
  display: block;
  padding: 8px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: var(--text);
}
.category-tile-label .chev { color: var(--hint); font-weight: 400; }

.trust-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 16px 6px;
  margin: 24px 0;
}
.trust-item {
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--hint);
  line-height: 1.35;
}
.trust-icon { display: block; font-size: 18px; margin-bottom: 5px; }

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-header h3 {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  margin: 0;
}
.section-link {
  background: none;
  border: none;
  color: var(--link);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
}

.popular-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
}
.popular-scroll::-webkit-scrollbar { display: none; }
.popular-card { flex: 0 0 auto; width: 140px; cursor: pointer; }
.popular-card .card-img-wrap img, .popular-card .card-img-wrap video {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
  border-radius: var(--radius);
  background: #ddd;
}
.popular-card-name { font-size: 12px; font-weight: 700; margin-top: 8px; line-height: 1.3; }
.popular-card-price { font-size: 13px; font-weight: 800; margin-top: 2px; }

.card-img-wrap { position: relative; }
.heart-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 6;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.88);
  color: var(--danger);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}
.heart-btn.active { background: #fff; }

.promo-row { display: flex; gap: 12px; margin: 24px 0 10px; }
.promo-tile {
  flex: 1;
  min-height: 130px;
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  cursor: pointer;
  color: #fff;
  border: none;
  text-align: left;
}
.promo-tile-a { background: linear-gradient(160deg, #4a4136, #7a6549); }
.promo-tile-b { background: linear-gradient(160deg, #322c26, #5e4a30); }
.promo-title { font-family: var(--font-serif); font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.promo-cta {
  align-self: flex-start;
  border: none;
  background: rgba(255,255,255,0.18);
  color: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

/* ---------- нижняя навигация ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  background: var(--bg);
  border-top: 1px solid rgba(0,0,0,0.08);
  padding: 7px 4px calc(7px + env(safe-area-inset-bottom));
}
.tabbar-btn {
  flex: 1;
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  color: var(--hint);
  cursor: pointer;
  padding: 4px 0;
}
.tabbar-btn.active { color: var(--accent); }
.tabbar-icon { position: relative; font-size: 20px; line-height: 1; }
.tabbar-btn.pulse .tabbar-icon { animation: tab-pulse 0.2s ease; }
@keyframes tab-pulse { 50% { transform: scale(1.25); } }

.fixed-bottom.above-tabbar { bottom: 84px; }

/* ---------- избранное / профиль ---------- */

.profile-header { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.profile-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--secondary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
  flex-shrink: 0;
}
.profile-name { font-size: 17px; font-weight: 800; }

.admin-row-link {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--secondary-bg);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 20px;
}

.profile-orders-title { margin-top: 4px; }

.profile-support-link {
  display: block;
  margin-top: 22px;
  margin-bottom: 100px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--secondary-bg);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
}

.status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.status-badge.status-new { background: #fde9c8; color: #7a5200; }
.status-badge.status-confirmed { background: #d7e7ff; color: #1a4c8f; }
.status-badge.status-completed { background: #d9f0dc; color: #1c6b2e; }
.status-badge.status-cancelled { background: #f6d9d6; color: #9c2b1f; }
