:root {
  --bg: #0f0d0a;
  --surface: rgba(28, 22, 18, 0.85);
  --surface-card: rgba(40, 32, 26, 0.9);
  --accent: #e85d6a;
  --accent-soft: rgba(232, 93, 106, 0.25);
  --chocolate: #c4a77d;
  --chocolate-dark: #8b6914;
  --text: #f5efe8;
  --text-muted: #a89b8a;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Outfit', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  position: relative;
  padding: clamp(1.5rem, 5vw, 2.5rem) 1.25rem;
  overflow: hidden;
}

.header-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 120% 80% at 50% -20%, var(--accent-soft), transparent 50%),
    radial-gradient(ellipse 80% 60% at 80% 20%, rgba(196, 167, 125, 0.15), transparent 45%),
    linear-gradient(180deg, var(--surface) 0%, transparent 100%);
  pointer-events: none;
}

.header-content {
  position: relative;
  text-align: center;
  padding-right: 3.5rem; /* место под фиксированную иконку корзины */
}

.cart-btn {
  position: fixed;
  top: max(0.5rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface-card);
  border: 1px solid rgba(196, 167, 125, 0.2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: var(--shadow-card);
}

.cart-count {
  background: var(--accent);
  color: #fff;
  min-width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
}

.logo {
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-shadow: 0 2px 20px rgba(232, 93, 106, 0.2);
}

.tagline {
  margin-top: 0.35rem;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-muted);
}

/* Main */
.main {
  flex: 1;
  padding: 0 1rem 2rem;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}

/* Loader */
.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  gap: 1rem;
}

.loader p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.loader-dots {
  display: flex;
  gap: 8px;
}

.loader-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: bounce 0.6s ease-in-out infinite alternate;
}

.loader-dots span:nth-child(2) { animation-delay: 0.15s; }
.loader-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  to { transform: translateY(-8px); opacity: 0.6; }
}

/* Error */
.error-msg {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--accent);
}

/* Empty */
.empty {
  text-align: center;
  padding: 3rem 1rem;
}

.empty-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.75rem;
  opacity: 0.8;
}

.empty p {
  color: var(--text-muted);
  font-size: 1rem;
}

.hidden {
  display: none !important;
}

/* Catalog grid */
.catalog {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding-bottom: 1rem;
}

@media (min-width: 420px) {
  .catalog {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Card */
.card {
  background: var(--surface-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  border: 1px solid rgba(196, 167, 125, 0.12);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: cardIn 0.4s ease backwards;
}

.card:active {
  transform: scale(0.98);
}

.card-image-wrap {
  aspect-ratio: 1;
  background: linear-gradient(145deg, rgba(40, 32, 26, 0.9), rgba(20, 16, 12, 0.95));
  position: relative;
  overflow: hidden;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  opacity: 0.5;
}

.card-body {
  padding: 1rem;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: 0.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.card-weight {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.card-price {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--chocolate);
}

.card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-actions {
  margin-top: 0.75rem;
}

.btn-add-cart {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-add-cart:active {
  opacity: 0.9;
}

.card-qty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.card-qty-btn {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid rgba(196, 167, 125, 0.25);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s;
}

.card-qty-btn:active {
  background: rgba(196, 167, 125, 0.2);
}

.card-qty-val {
  min-width: 1.75rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.95rem;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Stagger animation for cards */
.catalog .card:nth-child(1) { animation-delay: 0.05s; }
.catalog .card:nth-child(2) { animation-delay: 0.1s; }
.catalog .card:nth-child(3) { animation-delay: 0.15s; }
.catalog .card:nth-child(4) { animation-delay: 0.2s; }
.catalog .card:nth-child(5) { animation-delay: 0.25s; }
.catalog .card:nth-child(6) { animation-delay: 0.3s; }
.catalog .card:nth-child(7) { animation-delay: 0.35s; }
.catalog .card:nth-child(8) { animation-delay: 0.4s; }
.catalog .card:nth-child(n+9) { animation-delay: 0.45s; }

/* Cart panel */
.cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s;
}

.cart-overlay:not(.hidden) {
  opacity: 1;
}

.cart-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 360px;
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.cart-panel:not(.hidden) {
  transform: translateX(0);
}

.cart-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(196, 167, 125, 0.15);
}

.cart-panel-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.cart-close {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.cart-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.cart-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(196, 167, 125, 0.1);
}

.cart-item-name {
  font-weight: 500;
  margin-bottom: 0.35rem;
}

.cart-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.qty-btn {
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-card);
  border: 1px solid rgba(196, 167, 125, 0.2);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
}

.qty-val {
  min-width: 1.5rem;
  text-align: center;
  font-size: 0.9rem;
}

.cart-item-subtotal {
  font-weight: 600;
  color: var(--chocolate);
}

.cart-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(196, 167, 125, 0.15);
}

.cart-total {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.cart-total span {
  color: var(--chocolate);
}

.btn-checkout {
  width: 100%;
  padding: 0.85rem 1rem;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.cart-empty-msg {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
}

/* Checkout modal */
.checkout-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.6);
}

.checkout-modal.hidden {
  display: none;
}

.checkout-inner {
  background: var(--surface-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
  border: 1px solid rgba(196, 167, 125, 0.2);
}

.checkout-inner h2 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.checkout-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.checkout-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.field-label {
  font-size: 0.85rem;
  font-weight: 500;
}

.field-input {
  padding: 0.65rem 0.75rem;
  background: var(--bg);
  border: 1px solid rgba(196, 167, 125, 0.2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
}

.field-input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.checkout-buttons {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.btn-cancel {
  flex: 1;
  padding: 0.75rem;
  background: transparent;
  border: 1px solid rgba(196, 167, 125, 0.3);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.95rem;
  cursor: pointer;
}

.btn-submit {
  flex: 1;
  padding: 0.75rem;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.checkout-error {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--accent);
}

.checkout-success {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: #6b9b6b;
}

/* Footer */
.footer {
  padding: 1rem;
  text-align: center;
}

.footer p {
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.7;
}

/* Telegram Web App: expand viewport */
body.telegram-webapp {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
