:root {
  --green: #30B23B;
  --green-dark: #279130;
  --red: #E5544C;
  --red-dark: #C94540;
  --bg: #FFFFFF;
  --text: #1A1A1A;
  --muted: #9B9B9B;
  --border: #EFEFEF;
  --gray-bg: #F5F5F5;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

.view {
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

/* ===== Catalog header ===== */
.app-header {
  padding: 14px 16px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.app-header h1 {
  font-size: 17px;
  font-weight: 600;
}

/* ===== Catalog grid ===== */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px 10px;
  padding: 16px 12px;
}

.product-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  position: relative;
}

.product-emoji {
  font-size: 44px;
  line-height: 1;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-name {
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  color: var(--text);
  line-height: 1.3;
  min-height: 2.6em;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 2px;
}

.product-qty-badge {
  position: absolute;
  top: -4px;
  right: calc(50% - 34px);
  background: var(--green);
  color: white;
  border-radius: 999px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.product-controls {
  display: flex;
  gap: 4px;
  margin-top: 2px;
}

.btn-plus,
.btn-minus {
  flex: 1;
  height: 32px;
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 120ms;
  font-family: inherit;
}
.btn-plus {
  background: var(--green);
}
.btn-plus:active {
  background: var(--green-dark);
}
.btn-minus {
  background: var(--red);
}
.btn-minus:active {
  background: var(--red-dark);
}

/* ===== Sticky bottom CTA ===== */
.sticky-bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  background: var(--green);
  color: white;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  z-index: 20;
  transition: background 120ms;
}
.sticky-bottom:active {
  background: var(--green-dark);
}

/* ===== Cart view ===== */
.cart-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.cart-header h1 {
  flex: 1;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.6px;
}
.icon-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  color: var(--text);
  font-family: inherit;
}
.link-btn {
  background: none;
  border: none;
  color: var(--green);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px;
  font-family: inherit;
}

.cart-list {
  padding: 4px 0;
}

.cart-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.cart-item-emoji {
  font-size: 32px;
  line-height: 1;
  width: 40px;
  text-align: center;
}
.cart-item-info {
  flex: 1;
  min-width: 0;
}
.cart-item-name {
  font-size: 15px;
  font-weight: 600;
}
.cart-item-qty {
  color: var(--green);
  font-weight: 700;
  margin-left: 4px;
}
.cart-item-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}
.cart-item-price {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
}

.comment-box {
  padding: 14px 16px 20px;
  background: var(--gray-bg);
  margin-top: 12px;
}
.comment-box textarea {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  resize: none;
  outline: none;
  color: var(--text);
}
.comment-box textarea::placeholder {
  color: var(--text);
  opacity: 0.6;
}
.comment-hint {
  color: var(--muted);
  font-size: 13px;
  margin-top: 10px;
}

.cart-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

/* ===== Telegram dark theme support ===== */
body.tg-dark {
  --bg: #1F1F1F;
  --text: #FFFFFF;
  --border: #2E2E2E;
  --gray-bg: #2A2A2A;
  --muted: #8C8C8C;
}
