:root {
  --bg: var(--tg-theme-bg-color, #f5f6f8);
  --card: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1f2937);
  --muted: var(--tg-theme-hint-color, #6b7280);
  --button: var(--tg-theme-button-color, #208b5e);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --border: rgba(127, 127, 127, 0.18);
  --danger: #d64545;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0 16px 110px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--button);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: 24px;
}

h2 {
  margin-bottom: 12px;
  font-size: 18px;
}

.subtitle {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.cart-icon-button {
  position: relative;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: var(--card);
  color: var(--text);
  font-size: 22px;
}

#cartBadge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 21px;
  padding: 3px 6px;
  border-radius: 20px;
  background: var(--button);
  color: var(--button-text);
  font-size: 11px;
  font-weight: 700;
}

.search-section {
  margin-bottom: 22px;
}

#searchInput {
  width: 100%;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  outline: none;
  background: var(--card);
  color: var(--text);
}

.category-list {
  display: flex;
  gap: 9px;
  margin-bottom: 24px;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-list::-webkit-scrollbar {
  display: none;
}

.category-button {
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--card);
  color: var(--text);
}

.category-button.active {
  border-color: var(--button);
  background: var(--button);
  color: var(--button-text);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.menu-count {
  color: var(--muted);
  font-size: 13px;
}

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

.menu-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
}

.menu-image {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1.35 / 1;
  background: rgba(127, 127, 127, 0.12);
  font-size: 46px;
}

.menu-content {
  padding: 12px;
}

.menu-name {
  min-height: 44px;
  margin-bottom: 5px;
  font-size: 15px;
}

.menu-description {
  min-height: 37px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.menu-price {
  margin-bottom: 10px;
  color: var(--button);
  font-size: 15px;
}

.add-button {
  width: 100%;
  padding: 9px;
  border: 0;
  border-radius: 10px;
  background: var(--button);
  color: var(--button-text);
  font-weight: 700;
}

.bottom-cart {
  position: fixed;
  right: 14px;
  bottom: 14px;
  left: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
}

.bottom-cart span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
}

.bottom-cart button,
.primary-button {
  padding: 11px 16px;
  border: 0;
  border-radius: 11px;
  background: var(--button);
  color: var(--button-text);
  font-weight: 700;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.cart-panel {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  max-height: 85vh;
  padding: 20px 16px;
  overflow-y: auto;
  border-radius: 22px 22px 0 0;
  background: var(--card);
  transform: translateY(110%);
  transition: transform 0.25s ease;
}

.cart-panel.open {
  transform: translateY(0);
}

.cart-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  background: rgba(0, 0, 0, 0.45);
}

.cart-overlay.open {
  display: block;
}

.cart-panel-header,
.cart-summary > div,
.cart-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cart-panel-header p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.close-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text);
}

.cart-items {
  margin: 18px 0;
}

.cart-row {
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}

.cart-row-details {
  flex: 1;
}

.cart-row-details strong {
  display: block;
  margin-bottom: 4px;
}

.cart-row-details span {
  color: var(--muted);
  font-size: 13px;
}

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

.quantity-controls button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

.cart-summary {
  position: sticky;
  bottom: 0;
  padding-top: 15px;
  background: var(--card);
}

.cart-summary > div {
  margin-bottom: 14px;
}

.cart-summary .primary-button {
  width: 100%;
}

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

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 100;
  display: none;
  padding: 11px 16px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  transform: translateX(-50%);
  font-size: 13px;
}

.toast.show {
  display: block;
}

@media (min-width: 650px) {
  body {
    max-width: 720px;
    margin: 0 auto;
  }

  .bottom-cart {
    right: calc((100vw - 692px) / 2);
    left: calc((100vw - 692px) / 2);
  }
}

.menu-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.menu-state {
  grid-column: 1 / -1;
  padding: 40px 18px;
  color: var(--muted);
  text-align: center;
}

.menu-error p {
  margin-bottom: 14px;
}

.retry-button {
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--button);
  color: var(--button-text);
  font-weight: 700;
}
