:root {
  --phone-width: 430px;
  --phone-height: 932px;
  --bottom-safe-area: 18px;
  --chrome-height: 112px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  display: grid;
  min-height: max(100dvh, calc(var(--phone-height) + 48px));
  place-items: center;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 24px 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand, #2368d8) 34%, transparent);
  outline-offset: 2px;
}

.phone {
  position: relative;
  display: flex;
  width: var(--phone-width);
  height: var(--phone-height);
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: var(--page, #f6f7f8);
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.18);
}

.system-chrome {
  position: relative;
  z-index: 20;
  flex: none;
  color: var(--ink, #17191d);
  background: var(--navbar, rgba(255,255,255,0.94));
}

.statusbar {
  position: relative;
  display: grid;
  height: 48px;
  grid-template-columns: 1fr 126px 1fr;
  align-items: center;
  padding: 8px 20px 0;
  font-size: 12px;
  font-weight: 700;
}

.dynamic-island {
  width: 118px;
  height: 30px;
  justify-self: center;
  border-radius: 18px;
  background: #060606;
}

.status-icons {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  font-size: 11px;
}

.miniapp-navbar {
  position: relative;
  display: grid;
  height: 64px;
  grid-template-columns: 72px minmax(0, 1fr) 104px;
  align-items: center;
  padding: 0 14px 10px 16px;
}

.miniapp-navbar h1 {
  position: absolute;
  left: 50%;
  width: min(220px, calc(100% - 220px));
  margin: 0;
  overflow: hidden;
  font-size: 17px;
  font-weight: 750;
  text-align: center;
  text-overflow: ellipsis;
  transform: translateX(-50%);
  white-space: nowrap;
}

.nav-back {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  color: inherit;
  background: transparent;
  font-size: 18px;
}

.wechat-capsule {
  display: grid;
  width: 92px;
  height: 36px;
  grid-column: 3;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  justify-self: end;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.74);
  color: #111;
}

.wechat-capsule span {
  display: grid;
  height: 20px;
  place-items: center;
  font-size: 14px;
}

.wechat-capsule span + span {
  border-left: 1px solid rgba(15, 23, 42, 0.15);
}

.page-content {
  position: relative;
  min-height: 0;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.page-content::-webkit-scrollbar {
  display: none;
}

.tabbar {
  position: relative;
  z-index: 20;
  display: grid;
  flex: none;
  grid-template-columns: repeat(4, 1fr);
  padding: 8px 12px calc(var(--bottom-safe-area) + 8px);
  border-top: 1px solid var(--line, #e5e7eb);
  background: var(--tabbar, rgba(255,255,255,0.96));
}

.tabbar button {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted, #717782);
  font-size: 10px;
}

.tabbar button i {
  font-size: 19px;
}

.tabbar button[aria-current="page"] {
  color: var(--brand, #2368d8);
  font-weight: 700;
}

.actionbar {
  z-index: 20;
  display: flex;
  flex: none;
  gap: 10px;
  padding: 12px 18px calc(var(--bottom-safe-area) + 8px);
  border-top: 1px solid var(--line, #e5e7eb);
  background: var(--tabbar, rgba(255,255,255,0.97));
}

.touchbar {
  position: absolute;
  z-index: 50;
  bottom: 7px;
  left: 50%;
  width: 122px;
  height: 5px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: var(--touchbar, #111);
  pointer-events: none;
}

.overlay {
  position: absolute;
  z-index: 60;
  inset: 0;
  display: flex;
  align-items: flex-end;
  background: rgba(10, 15, 25, 0.48);
}

.sheet {
  width: 100%;
  max-height: 82%;
  overflow-y: auto;
  border-radius: 24px 24px 0 0;
  background: var(--sheet, #fff);
  color: var(--ink, #17191d);
  box-shadow: 0 -20px 50px rgba(15, 23, 42, 0.16);
}

.toast {
  position: absolute;
  z-index: 80;
  right: 24px;
  bottom: 104px;
  left: 24px;
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px 16px;
  border-radius: 8px;
  background: rgba(12, 17, 24, 0.92);
  color: #fff;
  font-size: 13px;
  font-weight: 650;
  text-align: center;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.2);
  animation: toast-in 180ms ease-out;
}

.pressable:active {
  transform: scale(0.98);
}

body.h5-mode {
  --bottom-safe-area: max(10px, env(safe-area-inset-bottom));
  display: block;
  min-height: 100dvh;
  padding: 0;
  background: var(--page, #f6f7f8);
}

body.h5-mode .phone {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  border: 0;
  box-shadow: none;
}

.h5-mode .h5-chrome {
  padding-top: env(safe-area-inset-top);
}

.h5-mode .h5-navbar {
  width: min(100%, 720px);
  height: 58px;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  margin: 0 auto;
  padding: 0 8px;
}

.h5-mode .h5-navbar h1 {
  width: min(400px, calc(100% - 120px));
}

.h5-mode .h5-mode-home {
  display: grid;
  width: 40px;
  height: 40px;
  grid-column: 3;
  place-items: center;
  justify-self: end;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 6px;
  background: transparent;
  color: inherit;
  text-decoration: none;
}

.h5-mode .page-content > * {
  width: min(100%, 720px);
  margin-right: auto;
  margin-left: auto;
}

.h5-mode .tabbar,
.h5-mode .actionbar {
  width: min(100%, 720px);
  align-self: center;
}

.h5-mode .sheet {
  max-width: 720px;
  margin-right: auto;
  margin-left: auto;
}

.h5-mode .toast {
  right: max(24px, calc((100% - 672px) / 2));
  left: max(24px, calc((100% - 672px) / 2));
}

.h5-mode .touchbar {
  display: none;
}

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

@media (max-width: 500px) {
  body {
    min-height: 100dvh;
    place-items: stretch;
    overflow: hidden;
    padding: 0;
  }
  .phone {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border: 0;
    box-shadow: none;
  }
}

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