/* A phone-sized H5 canvas, including its fixed navigation and overlays. */
:root {
  --h5-width: min(100%, 480px);
  --h5-gutter: max(0px, calc((100% - 480px) / 2));
}

html {
  background: #eef0f5;
}

body {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  background: #f6f7fb;
}

uni-app,
uni-page,
uni-page-wrapper,
uni-page-body {
  max-width: 480px;
}

/* These components use viewport positioning in the compiled uni-app. */
.tab-bar,
.uni-navbar--fixed,
.uni-popup,
.uni-drawer,
.h5-document-panel,
.tui-header > .tui-btn,
.tui-header .keyboard,
.tui-NavHeader[style*="fixed"],
uni-page-head .uni-page-head {
  box-sizing: border-box;
  left: var(--h5-gutter) !important;
  right: var(--h5-gutter) !important;
  width: var(--h5-width) !important;
  max-width: 480px;
}

/* Popup transitions are themselves fixed; anchor them to this canvas. */
.uni-popup {
  top: var(--window-top, 0px);
  bottom: 0;
  contain: layout;
}

uni-page-body:has(.tab-bar) {
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}

/* Both rows fit the available width; icons and labels keep their own space. */
.tui-card .tui-content {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 8px;
}

.tui-card .tui-content > .item {
  width: auto !important;
  height: auto !important;
  min-width: 0;
  min-height: 88px;
  margin-top: 0 !important;
  padding: 12px 4px !important;
  gap: 6px;
  box-sizing: border-box;
}

.tui-card .tui-content > .item > uni-image {
  flex: 0 0 36px;
  width: 36px !important;
  height: 36px !important;
}

.tui-card .tui-content .item uni-image > div {
  background-size: contain !important;
  background-position: center !important;
}

.tui-card .tui-content > .item > .title {
  flex-shrink: 0;
  max-width: 100% !important;
  padding-top: 0 !important;
  font-size: 12px !important;
  line-height: 1.5;
  text-align: center;
  overflow-wrap: anywhere;
}

.tui-card .tui-content > .item:last-child {
  grid-column: span 2;
  padding: 12px !important;
}

.tui-card .tui-content .tui-itemLeft {
  min-width: 0;
}

.tui-card .tui-content .tui-itemRight {
  flex: 0 0 48px;
  width: 48px !important;
  height: 48px !important;
}

.tui-card .tui-content .tui-positionBadge {
  top: 2px !important;
  right: 2px !important;
}

.h5-product-header {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 64px;
  align-items: center;
  min-height: 52px;
  padding: env(safe-area-inset-top, 0px) 12px 0;
  background: #f6f7fb;
  color: #222;
}

.h5-product-header h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
}

.h5-product-back {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.h5-product-back::before {
  content: "";
  width: 8px;
  height: 8px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.h5-product-back:focus-visible {
  outline: 2px solid #487ff3;
  outline-offset: 2px;
}

.h5-product-back:active {
  background: #e7ebf3;
}

@media (min-width: 481px) {
  body {
    box-shadow: 0 0 24px #18243a0a;
  }

  /* Login footers and member-page controls also belong to the H5 canvas. */
  uni-page-body .bottom {
    max-width: 480px;
  }

  .tui-submit[style],
  .tui-submit {
    max-width: 445px;
  }
}
