:root {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.app-shell {
  max-width: 1360px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  padding-bottom: 72px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px 14px;
  background: var(--ui-white);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topbar h1 {
  flex: 1;
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand-weak);
  color: var(--brand);
  font-size: 18px;
}

.page {
  padding: 14px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px 0 10px;
}

.section-title h2 {
  margin: 0;
  font-size: 17px;
}

.link-btn {
  background: transparent;
  color: var(--brand);
  padding: 4px 0;
}

.primary-btn,
.secondary-btn,
.danger-btn {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 600;
}

.primary-btn {
  background: var(--brand);
  color: var(--ui-white);
}

.secondary-btn {
  background: var(--brand-weak);
  color: var(--brand);
}

.danger-btn {
  border: 1px solid var(--ui-border-strong);
  background: var(--ui-white);
  color: var(--ui-text);
}

.product-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.product-card,
.list-card,
.form-card {
  border-radius: 8px;
  background: var(--panel);
  box-shadow: none;
}

.product-card {
  display: grid;
  grid-template-columns: 104px minmax(220px, 1fr) minmax(210px, 0.9fr) 180px;
  align-items: center;
  gap: 16px;
  min-height: 128px;
  padding: 12px;
}

.product-image {
  display: grid;
  place-items: center;
  width: 104px;
  height: 104px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--ui-white);
}

.image-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--ui-white);
}

.image-frame img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
}

.image-preview-trigger {
  padding: 0;
  border: 1px solid var(--line);
  color: inherit;
  cursor: zoom-in;
}

.image-placeholder {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  background: var(--ui-white);
}

.image-placeholder[hidden] {
  display: none;
}

.product-summary,
.product-options,
.product-purchase {
  min-width: 0;
}

.product-summary {
  display: grid;
  gap: 5px;
}

.product-title {
  margin: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
}

.product-summary p,
.product-options p {
  margin: 0;
}

.product-options {
  display: grid;
  gap: 7px;
}

.product-purchase {
  display: grid;
  gap: 9px;
}

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

.compact-select {
  min-width: 0;
}

.store-selector {
  position: relative;
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.store-selector-current,
.store-selector-option {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) minmax(0, 1.3fr) 24px;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  color: var(--text);
  text-align: left;
  background: transparent;
}

.store-selector-current strong,
.store-selector-option strong,
.store-selector-address {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.store-selector-address {
  color: var(--muted);
  font-size: 13px;
}

.store-selector-chevron,
.store-selector-check {
  justify-self: end;
  color: var(--brand);
  font-size: 18px;
  font-weight: 600;
}

.store-selector-options {
  border-top: 1px solid var(--line);
}

.store-selector-option + .store-selector-option {
  border-top: 1px solid var(--line);
}

.store-selector-option:hover,
.store-selector-option.selected {
  background: var(--brand-weak);
}

.product-card h3,
.list-card h3 {
  margin: 0 0 6px;
  font-size: 15px;
  line-height: 1.35;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.field-label {
  display: block;
  margin: 10px 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.price {
  color: var(--accent);
  font-size: 17px;
  font-weight: 600;
}

.price-stack {
  display: grid;
  gap: 2px;
}

.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.textarea {
  min-height: 78px;
  padding-top: 10px;
  resize: vertical;
}

.tabs,
.segmented {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tab,
.chip {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--ui-white);
  color: var(--muted);
  border: 1px solid var(--line);
}

.tab.active,
.chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 2vh 2vw;
  background: var(--ui-overlay);
}

.image-lightbox-content {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 96vw;
  height: 96vh;
}

.image-lightbox-canvas {
  display: block;
  width: 100%;
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  cursor: grab;
  touch-action: none;
}

.image-lightbox-canvas.dragging {
  cursor: grabbing;
}

.image-lightbox-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 100%;
  min-height: 100%;
}

.image-lightbox-stage > img {
  flex: 0 0 auto;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  object-fit: contain;
  object-position: center;
  user-select: none;
}

.image-lightbox-stage > .image-placeholder {
  width: min(420px, 70vw);
  height: min(420px, 70vw);
}

.image-lightbox-toolbar {
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 0 56px 8px;
}

.image-lightbox-toolbar button {
  min-width: 42px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 6px;
  color: var(--ui-white);
  font-size: 18px;
  background: rgba(15, 21, 25, 0.72);
}

.image-lightbox-close,
.image-lightbox-nav {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 50%;
  color: #fff;
  font-size: 30px;
  line-height: 1;
  background: rgba(15, 21, 25, 0.72);
}

.image-lightbox-close {
  top: 0;
  right: 0;
}

.image-lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
}

.image-lightbox-nav.previous {
  left: 0;
}

.image-lightbox-nav.next {
  right: 0;
}

.image-lightbox-counter {
  position: absolute;
  bottom: 0;
  left: 50%;
  padding: 5px 9px;
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  background: rgba(15, 21, 25, 0.72);
  transform: translateX(-50%);
}

.list-card {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
  padding: 12px;
}

.cart-item {
  grid-template-columns: auto 72px 1fr auto;
  align-items: center;
}

.cart-item-image {
  width: 72px;
  height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.checkout-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.checkout-item:last-child {
  border-bottom: 0;
}

.checkout-item-image {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.qty {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
}

.qty button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand-weak);
  color: var(--brand);
  font-weight: 600;
}

.checkout-bar {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #fff;
  border-top: 1px solid var(--line);
}

.quantity-input {
  width: 64px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--ui-white);
  color: var(--text);
  text-align: center;
  outline: none;
  appearance: textfield;
}

.quantity-input::-webkit-inner-spin-button,
.quantity-input::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

.checkout-summary,
.account-toggle {
  display: flex;
  align-items: center;
  gap: 14px;
}

.account-toggle {
  gap: 6px;
  font-weight: 700;
  white-space: nowrap;
}

.inline-state,
.pickup-location-static {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--ui-gray);
}

.pickup-location-static {
  align-items: flex-start;
  flex-direction: column;
}

.error-state {
  border-color: var(--ui-border-strong);
  background: var(--ui-white);
  color: var(--ui-text);
}

.form-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.form-card h2 {
  margin: 0;
  font-size: 16px;
}

.order-detail-item,
.payment-record {
  display: grid;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.order-detail-item:last-of-type,
.payment-record:last-of-type {
  border-bottom: 0;
}

.order-detail-item {
  grid-template-columns: 56px minmax(0, 1fr) auto;
}

.order-detail-item-image {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--ui-white);
}

.order-detail-item-copy,
.payment-record-main,
.payment-record-amount {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.order-detail-item-copy strong,
.order-detail-item-copy span {
  overflow-wrap: anywhere;
}

.order-detail-item-amount,
.payment-record-amount {
  text-align: right;
}

.payment-record {
  grid-template-columns: minmax(0, 1fr) auto;
}

.compact-empty {
  min-height: 72px;
}

.radio-card {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.radio-card.active {
  border-color: var(--brand);
  background: var(--brand-weak);
}

.order-status {
  width: max-content;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--ui-gray);
  color: var(--ui-text);
  font-size: 12px;
  font-weight: 600;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(1360px, 100%);
  transform: translateX(-50%);
  background: #fff;
  border-top: 1px solid var(--line);
}

.bottom-nav button {
  min-height: 58px;
  padding: 6px 4px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.bottom-nav button.active {
  color: var(--brand);
  font-weight: 600;
}

.empty {
  padding: 34px 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
}

.pickup-store-state {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ui-gray);
  color: var(--muted);
  line-height: 1.5;
}

.pickup-store-state.error {
  border-color: var(--ui-border-strong);
  background: var(--ui-white);
  color: var(--ui-text);
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-radius: 8px;
  background: var(--panel);
}

.profile-info {
  flex: 1;
  min-width: 0;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stack {
  display: grid;
  gap: 10px;
}

.small {
  font-size: 12px;
}

.load-more {
  display: block;
  min-width: 180px;
  margin: 16px auto 0;
}

.login-page {
  display: grid;
  min-height: calc(100vh - 53px);
  place-items: center;
}

.login-panel {
  width: min(440px, 100%);
  padding: 24px;
}

.login-heading {
  margin-bottom: 6px;
}

.login-heading p {
  margin: 6px 0 0;
}

.address-row,
.address-editor,
.cart-subtotal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.address-row {
  min-height: 42px;
  border-bottom: 1px solid var(--line);
}

.address-row > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.address-editor .secondary-btn {
  flex: 0 0 auto;
}

.cart-subtotal {
  justify-content: flex-start;
  margin-top: 6px;
}

.cart-subtotal .price-stack {
  grid-auto-flow: column;
  align-items: baseline;
  gap: 8px;
}

.app-toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 2000;
  width: min(440px, calc(100vw - 24px));
  padding: 12px 14px;
  border: 1px solid var(--ui-border-strong);
  border-radius: 8px;
  background: var(--ui-black);
  color: var(--ui-white);
  line-height: 1.4;
  text-align: center;
  transform: translateX(-50%);
}

.app-toast.success {
  background: var(--ui-white);
  color: var(--ui-black);
}

.app-shell[data-route="cart"] .checkout-bar {
  bottom: 58px;
}

@media (max-width: 900px) {
  .product-card {
    grid-template-columns: 88px minmax(0, 1fr);
    align-items: start;
    gap: 12px;
  }

  .product-image {
    width: 88px;
    height: 88px;
  }

  .product-options,
  .product-purchase {
    grid-column: 1 / -1;
  }

  .product-purchase {
    grid-template-columns: 1fr;
    align-items: end;
  }

  .product-purchase .field-label {
    grid-column: 1 / -1;
  }

  .product-purchase-actions {
    width: 100%;
    min-width: 0;
  }

  .store-selector-current,
  .store-selector-option {
    grid-template-columns: minmax(90px, 0.8fr) minmax(0, 1.2fr) 22px;
    gap: 8px;
  }

  .image-lightbox {
    padding: 12px;
  }

  .image-lightbox-content {
    width: 96vw;
    height: 88vh;
  }

  .order-detail-item {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .order-detail-item-image {
    width: 52px;
    height: 52px;
  }

  .order-detail-item-amount {
    grid-column: 2;
    text-align: left;
  }
}

@media (max-width: 360px) {

  .page {
    padding: 10px;
  }

  .product-card {
    grid-template-columns: 76px minmax(0, 1fr);
    padding: 10px;
  }

  .product-image {
    width: 76px;
    height: 76px;
  }

  .bottom-nav button {
    font-size: 11px;
  }

  .cart-item {
    grid-template-columns: auto 62px 1fr;
  }

  .cart-item-image {
    width: 62px;
    height: 62px;
  }

  .checkout-item {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .checkout-item-image {
    width: 44px;
    height: 44px;
  }

  .checkout-item .price-stack,
  .checkout-item > strong {
    grid-column: 2;
    justify-self: start;
  }
}
