
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f4f5f8;
  color: #20242a;
  font-family: Arial, sans-serif;
}

header {
  background: white;
  padding: 22px 16px;
}

header h1 {
  margin: 0;
  font-size: 24px;
}

header p {
  color: #888;
  font-size: 14px;
}

#search {
  width: 100%;
  padding: 14px;
  border: 1px solid #ddd;
  border-radius: 12px;
  font-size: 16px;
}

main {
  max-width: 900px;
  margin: auto;
  padding: 16px;
}

.categories {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.categories button {
  border: 0;
  background: white;
  padding: 12px;
  border-radius: 20px;
  white-space: nowrap;
  cursor: pointer;
}

.categories button.active {
  background: #2481cc;
  color: white;
}

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

.product {
  min-width: 0;
  background: white;
  padding: 12px;
  border-radius: 16px;
}

.product-photo {
  font-size: 55px;
  background: #edf1f5;
  text-align: center;
  padding: 20px 0;
  border-radius: 12px;
}

.product h3 {
  font-size: 15px;
}

.product p {
  font-weight: bold;
}

.product button,
#clear-cart {
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}

.product button {
  background: #2481cc;
  color: white;
}

.cart {
  margin-top: 25px;
  background: white;
  border-radius: 16px;
  padding: 16px;
}

.cart-item {
  border-bottom: 1px solid #eee;
  padding: 12px 0;
}

.cart-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cart-controls button {
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

#clear-cart {
  background: #edf1f5;
}

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

/* Фотографии карточек */
img.product-photo {
  display: block;
  width: 100%;
  height: 150px;
  object-fit: cover;
  border-radius: 12px;
  background: #edf1f5;
  padding: 0;
  font-size: initial;
}

.product-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 150px;
}

/* Кнопка подробнее */
.details-button {
  background: #edf1f5 !important;
  color: #20242a !important;
  margin-bottom: 8px;
}

/* Модальное окно товара */
.product-dialog {
  width: calc(100% - 32px);
  max-width: 430px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px;
  border: none;
  border-radius: 20px;
  background: white;
  color: #20242a;
  position: fixed;
}

.product-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.close-product {
  display: block;
  margin-left: auto;
  margin-bottom: 10px;
  background: #edf1f5;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
}

#detail-image {
  width: 100%;
  height: 240px;
  object-fit: cover;
  border-radius: 14px;
}

#detail-fallback {
  font-size: 80px;
  text-align: center;
  padding: 40px;
}

[hidden] {
  display: none !important;
}

#detail-description {
  color: #666;
  line-height: 1.6;
}

#detail-price {
  font-size: 24px;
}

.detail-buy {
  width: 100%;
  background: #2481cc;
  color: white;
  padding: 15px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
}
