:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --text: #101318;
  --muted: #6f7a85;
  --accent: #ff6b18;
  --green: #49b563;
  --line: #e4e8ee;
  --shadow: 0 10px 30px rgba(25, 31, 42, 0.12);
}

* {
  box-sizing: border-box;
}

@media (prefers-reduced-motion: no-preference) {
  * {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

body.theme-animating,
body.theme-animating .app,
body.theme-animating .topbar,
body.theme-animating .pickup-strip,
body.theme-animating .product-card,
body.theme-animating .category-card,
body.theme-animating .tabbar,
body.theme-animating .profile-card,
body.theme-animating .cart-summary,
body.theme-animating dialog,
body.theme-animating .modal-body,
body.theme-animating .brand-chip,
body.theme-animating .search-box,
body.theme-animating .product-stock,
body.theme-animating .flavor-chip,
body.theme-animating .checkout-panel {
  transition: background-color 0.36s ease, color 0.36s ease, border-color 0.36s ease, box-shadow 0.36s ease;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.16s ease, border-color 0.16s ease, background-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

button:active {
  transform: scale(0.96);
}

.app {
  max-width: 430px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  padding-bottom: 88px;
  position: relative;
  overflow: hidden;
}

.topbar {
  height: 82px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--surface);
  box-shadow: 0 2px 16px rgba(33, 40, 50, 0.08);
  position: sticky;
  top: 0;
  z-index: 4;
}

.avatar {
  width: 45px;
  height: 45px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #111;
  background: radial-gradient(circle at 35% 25%, #fff 0 16%, #cfd3d8 17% 36%, #111 37% 66%, #f4f4f4 67%);
  font-size: 10px;
  font-weight: 900;
  overflow: hidden;
  background-size: cover;
  background-position: center;
}

.profile {
  display: grid;
  gap: 2px;
  flex: 1;
}

.profile strong {
  font-size: 15px;
}

.balance {
  color: #24a044;
  font-weight: 800;
  font-size: 13px;
}

.profile small,
.empty-view p,
.product-stock,
.tab {
  color: var(--muted);
}

.icon-button,
.pill-button,
.cart-button,
.like-button,
.close {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(23, 30, 38, 0.08);
}

.theme-icon {
  grid-area: 1 / 1;
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  transition: opacity 0.24s ease, transform 0.3s ease;
}

.theme-icon.sun {
  opacity: 0;
  transform: rotate(-60deg) scale(0.55);
}

body.dark .theme-icon.moon {
  opacity: 0;
  transform: rotate(55deg) scale(0.55);
}

body.dark .theme-icon.sun {
  opacity: 1;
  transform: rotate(0) scale(1);
}

main {
  padding: 18px 20px 0;
}

.pickup-strip {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 4px 18px rgba(30, 35, 45, 0.06);
}

.pickup-strip div {
  display: grid;
  gap: 2px;
}

.pickup-strip span {
  color: var(--muted);
  font-size: 12px;
}

.pickup-strip strong {
  font-size: 14px;
}

.pill-button {
  min-width: 74px;
  height: 34px;
  border-radius: 10px;
  color: var(--accent);
  background: transparent;
}

h1,
h2 {
  margin: 14px 0 14px;
  font-size: 20px;
  line-height: 1.2;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: viewIn 0.22s ease both;
}

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

.category-card {
  min-height: 178px;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  padding: 0;
  color: #fff;
  box-shadow: var(--shadow);
  position: relative;
  background: #0f151d;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.category-card img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform 0.18s ease;
}

.category-card:active img {
  transform: scale(0.98);
}

.category-card:active,
.product-card:active {
  transform: scale(0.985);
}

.category-card strong {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  padding: 4px 6px;
  border-radius: 7px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
  text-align: center;
  font-size: 12px;
}

.product-card {
  border: 0;
  background: var(--surface);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow);
  text-align: left;
  min-height: 334px;
  overflow: hidden;
  animation: cardIn 0.26s ease both;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.back-button {
  height: 36px;
  border: 0;
  padding: 0 2px;
  margin-bottom: 4px;
  background: transparent;
  color: var(--accent);
  font-weight: 800;
}

.brand-filter {
  display: flex;
  gap: 8px;
  margin: 2px 0 14px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.brand-chip {
  min-height: 34px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 13px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 800;
}

.brand-chip.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.product-image {
  height: 164px;
  border-radius: 8px;
  background: linear-gradient(135deg, #e7f2eb, #cbd4d8);
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}

.product-image::before {
  content: "";
  position: absolute;
  inset: 18px 42px 18px 46px;
  border-radius: 11px;
  background: linear-gradient(160deg, var(--image-a), var(--image-b));
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.3), 12px 10px 20px rgba(0, 0, 0, 0.18);
}

.product-image.has-photo {
  background: linear-gradient(145deg, #f8fafc, #e6ebef);
}

.product-image.has-photo::before,
.modal-image.has-photo::before {
  display: none;
}

.product-image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: top center;
  padding: 0;
  filter: drop-shadow(0 12px 14px rgba(0, 0, 0, 0.18));
}

.cashback {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 7px;
  border-radius: 6px;
  background: var(--green);
  color: white;
  font-size: 12px;
  font-weight: 900;
}

.rating {
  position: absolute;
  left: 8px;
  bottom: 8px;
  border-radius: 8px;
  background: rgba(27, 31, 36, 0.75);
  color: white;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 800;
}

.brand {
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.product-name {
  display: block;
  min-height: 38px;
  margin: 7px 0;
  font-size: 14px;
  line-height: 1.35;
}

.price-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 8px 0;
}

.price {
  color: var(--green);
  font-size: 18px;
  font-weight: 900;
}

s {
  color: #9ba4ad;
  font-weight: 700;
}

.product-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px 38px;
  gap: 7px;
  align-items: center;
}

.product-stock {
  min-width: 0;
  height: 40px;
  display: grid;
  place-items: center start;
  padding: 5px 8px;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.1;
}

.round-actions {
  display: contents;
}

.button-icon {
  width: 19px;
  height: 19px;
  display: block;
  fill: none;
  stroke: currentColor;
}

.cart-button,
.like-button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 18px;
  transition: transform 0.16s ease, background-color 0.16s ease, border-color 0.16s ease;
}

.cart-button:active,
.like-button:active {
  transform: scale(0.9);
}

.cart-button {
  color: var(--accent);
}

.cart-product-card {
  min-height: 0;
  padding-bottom: 10px;
}

.cart-flavor {
  display: block;
  min-height: 28px;
  margin: 0 0 8px;
  padding: 7px 8px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
}

.remove-cart-button {
  width: 100%;
  height: 36px;
  border: 1px solid rgba(255, 107, 24, 0.25);
  border-radius: 8px;
  background: rgba(255, 107, 24, 0.08);
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
}

.search-box {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  margin-bottom: 18px;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(30, 35, 45, 0.08);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.empty-view {
  min-height: calc(100vh - 190px);
  place-items: center;
  align-content: center;
  text-align: center;
  padding: 40px 24px;
}

.empty-view.active {
  display: grid;
}

.empty-icon {
  color: #717b84;
  font-size: 66px;
  line-height: 1;
}

.empty-view h2 {
  margin-bottom: 0;
}

.profile-card,
.cart-summary {
  background: var(--surface);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.checkout-panel {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.checkout-panel .cart-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  padding: 0;
  box-shadow: none;
  background: transparent;
}

.checkout-panel .cart-summary span {
  color: var(--muted);
}

.checkout-panel .primary-button {
  margin-top: 2px;
}

.profile-card {
  display: grid;
  gap: 12px;
}

.profile-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.profile-line:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.profile-line span {
  color: var(--muted);
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(430px, 100%);
  height: 76px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  box-shadow: 0 -4px 18px rgba(30, 35, 45, 0.1);
  z-index: 5;
}

.tab {
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  font-size: 10px;
  line-height: 1;
  min-width: 0;
  color: var(--muted);
}

.tab.active svg {
  animation: tabPop 0.22s ease both;
}

.tab svg {
  width: 20px;
  height: 20px;
  display: block;
  fill: none !important;
  stroke: currentColor !important;
  stroke-width: 1.8;
  vector-effect: non-scaling-stroke;
}

.tab svg * {
  fill: none !important;
  stroke: currentColor !important;
}

.tab-icon {
  position: relative;
  display: grid;
  place-items: center;
}

.cart-badge {
  position: absolute;
  top: -8px;
  right: -9px;
  min-width: 16px;
  height: 16px;
  display: none;
  place-items: center;
  padding: 0 5px;
  border: 2px solid var(--surface);
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
}

.cart-badge.visible {
  display: grid;
}

.cart-badge.bump {
  animation: badgeBump 0.34s ease both;
}

.tab.active {
  color: var(--accent);
}

dialog {
  max-width: 390px;
  width: calc(100% - 28px);
  max-height: calc(100dvh - 18px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

dialog[open] {
  animation: dialogFade 0.18s ease both;
}

dialog[open] .modal,
dialog[open] .pickup-modal {
  animation: modalPop 0.2s ease both;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.42);
}

.modal {
  max-height: calc(100dvh - 18px);
  display: grid;
  grid-template-rows: auto 1fr;
  position: relative;
  overflow: hidden;
}

.close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 24px;
  z-index: 2;
}

.modal-image {
  height: 176px;
  border-radius: 8px 8px 0 0;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.18) 34%, transparent 58%),
    linear-gradient(135deg, #edf5ef, #cbd5da);
  position: relative;
  overflow: hidden;
  cursor: default;
}

.modal-image::before {
  content: "";
  position: absolute;
  inset: 28px 128px 28px;
  border-radius: 12px;
  background: linear-gradient(160deg, var(--image-a), var(--image-b));
}

.modal-image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  padding: 16px 18px;
  filter: drop-shadow(0 18px 22px rgba(0, 0, 0, 0.2));
  transition: transform 0.18s ease;
}

.modal-image.zoomable {
  cursor: zoom-in;
}

.modal-image.zoomable:active img {
  transform: scale(0.97);
}

.modal-body {
  display: grid;
  gap: 10px;
  padding: 16px 18px 18px;
  overflow: hidden;
}

.modal-body h2 {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  font-size: 19px;
  line-height: 1.2;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.modal-body p {
  margin: 0;
}

.modal-price {
  display: flex;
  gap: 10px;
  align-items: baseline;
}

.modal-price strong {
  color: var(--green);
  font-size: 24px;
  line-height: 1;
}

.modal-description {
  color: var(--muted);
  display: -webkit-box;
  line-height: 1.45;
  margin: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.flavor-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 78px;
  margin: 4px 0;
  overflow: auto;
}

.flavor-chip {
  padding: 6px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.flavor-chip.active {
  border-color: var(--accent);
  background: rgba(255, 107, 24, 0.14);
  color: var(--accent);
}

.primary-button {
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 900;
}

.primary-button:disabled {
  opacity: 0.74;
  cursor: wait;
}

.image-modal {
  position: relative;
  min-height: 340px;
  display: grid;
  place-items: center;
  padding: 22px;
  background: var(--surface);
}

.image-modal img {
  width: 100%;
  max-height: min(70dvh, 560px);
  object-fit: contain;
  border-radius: 8px;
  filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.22));
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  z-index: 20;
  max-width: min(340px, calc(100% - 32px));
  padding: 11px 14px;
  border-radius: 8px;
  background: #111827;
  color: white;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
  font-size: 14px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px) scale(0.96);
}

.toast.show {
  animation: toastIn 1.6s ease both;
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes tabPop {
  0% {
    transform: scale(0.82);
  }
  70% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes badgeBump {
  0% {
    transform: scale(0.7);
  }
  55% {
    transform: scale(1.22);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes dialogFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalPop {
  from {
    transform: translateY(12px) scale(0.96);
  }
  to {
    transform: translateY(0) scale(1);
  }
}

@keyframes toastIn {
  0% {
    opacity: 0;
    transform: translate(-50%, 12px) scale(0.96);
  }
  12%,
  82% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, 8px) scale(0.98);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

.pickup-modal {
  position: relative;
  padding: 18px;
}

.pickup-modal h2 {
  margin: 0 0 14px;
}

.pickup-options {
  display: grid;
  gap: 10px;
}

.pickup-option {
  display: grid;
  gap: 5px;
  width: 100%;
  height: auto;
  min-height: 72px;
  padding: 12px;
  text-align: left;
}

.pickup-option strong {
  font-size: 15px;
}

.pickup-option span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

body.dark {
  color-scheme: dark;
  --bg: #111418;
  --surface: #191e24;
  --surface-2: #232a32;
  --text: #f8fafc;
  --muted: #9aa5b1;
  --line: #303842;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

@media (max-width: 360px) {
  main {
    padding-inline: 14px;
  }

  .category-grid,
  .product-grid {
    gap: 12px;
  }

  .product-card {
    padding: 10px;
  }
}
