/* Device-first overrides. Loaded last so phones/tablets beat the desktop mock. */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  overflow-x: hidden;
  max-width: 100%;
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
}

a,
button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding-top: env(safe-area-inset-top);
  min-height: calc(58px + env(safe-area-inset-top));
  box-shadow: 0 1px 0 #e8f0f6;
}

.menu-toggle,
.nav-backdrop,
.mobile-nav,
.login-pill-mobile,
.language-header-mobile {
  display: none;
}

.menu-toggle {
  width: 44px;
  height: 44px;
  border: 0;
  background: none;
  padding: 10px 8px;
  cursor: pointer;
  flex-shrink: 0;
}

.menu-toggle span {
  display: block;
  height: 2px;
  margin: 6px 0;
  background: #102A2C;
  border-radius: 2px;
  transition: transform .2s ease, opacity .2s ease;
}

body.menu-open .menu-toggle span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

body.menu-open .menu-toggle span:nth-child(2) {
  opacity: 0;
}

body.menu-open .menu-toggle span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

.nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 44;
  background: #001f49a8;
}

.mobile-nav {
  position: fixed;
  z-index: 45;
  top: 0;
  right: 0;
  width: min(320px, 86vw);
  height: 100%;
  padding: calc(72px + env(safe-area-inset-top)) 22px calc(24px + env(safe-area-inset-bottom));
  background: #fff;
  box-shadow: -12px 0 32px #052b5d2b;
  overflow-y: auto;
  display: none;
  flex-direction: column;
  gap: 4px;
}

.mobile-nav a,
.mobile-nav button {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 12px 8px;
  border: 0;
  border-bottom: 1px solid #e8f0f6;
  background: none;
  color: #102A2C;
  text-align: left;
  text-decoration: none;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.mobile-nav .login-pill,
.mobile-nav .app-trigger {
  margin-top: 12px;
  border: 0;
  border-radius: 24px;
  text-align: center;
  color: #fff;
  background: linear-gradient(90deg, #4A9BE8, #1E6BB8);
}

.mobile-nav .app-trigger {
  background: linear-gradient(90deg, #0D3A6B, #1E6BB8);
}

body.menu-open {
  overflow: hidden;
}

body.menu-open .mobile-nav {
  display: flex !important;
}

body.menu-open .nav-backdrop {
  display: block !important;
}

/* Phones and small tablets: stacked, readable, tappable */
@media (max-width: 1023px) {
  .desktop-nav,
  .header-actions {
    display: none !important;
  }

  .mobile-account {
    margin-left: auto;
    display: flex !important;
    align-items: center;
    gap: 8px;
  }

  .language-header-mobile,
  .menu-toggle {
    display: block;
  }

  .login-pill-mobile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 36px;
    padding: 8px 14px;
    font-size: 12px;
  }

  .language-header-mobile {
    min-width: 44px;
    min-height: 44px;
    font-size: 14px;
    font-weight: 700;
    color: #102A2C;
    border: 0;
    background: none;
    cursor: pointer;
  }

  .site-header {
    height: auto;
    min-height: calc(52px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 16px 0;
    gap: 8px;
  }

  .brand strong {
    font-size: 14px;
  }

  .hero {
    height: auto;
    min-height: 280px;
    overflow: hidden;
    padding: 72px 20px 36px;
  }

  .world-map {
    width: 160% !important;
    max-width: none !important;
    height: auto !important;
    left: 50% !important;
    top: 20px !important;
    transform: translateX(-38%);
    object-fit: contain;
  }

  html[lang="en"] .hero-copy p,
  html[lang="zh-CN"] .hero-copy p,
  .hero-copy p {
    white-space: normal !important;
    font-size: 15px !important;
    line-height: 1.45 !important;
    max-width: 36em;
  }

  html[lang="en"] .hero-copy h1,
  html[lang="zh-CN"] .hero-copy h1,
  .hero-copy h1 {
    font-size: clamp(26px, 7.2vw, 36px) !important;
    line-height: 1.15 !important;
    max-width: 16ch;
    white-space: normal;
  }

  .hero-copy {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    z-index: 5;
    color: #fff;
  }

  .desktop-app-card {
    display: none !important;
  }

  .hero-shortcuts {
    display: flex !important;
    position: relative;
    left: auto;
    top: auto;
    width: 100%;
    max-width: 420px;
    height: 48px;
    margin-top: 22px;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(5, 57, 117, .72);
  }

  .hero-shortcuts a,
  .hero-shortcuts button {
    flex: 1;
    min-height: 48px;
    border: 0;
    background: none;
    color: #eaf4ff;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
  }

  .hero-shortcuts a + button {
    border-left: 1px solid #3879b6;
  }

  .content-sheet {
    position: relative;
    z-index: 6;
    min-height: 0 !important;
    margin-top: -18px;
    padding: 18px 16px 28px !important;
    border-radius: 18px 18px 0 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .mobile-quickbar,
  .core-card,
  .mobile-app-card {
    display: block !important;
    position: static !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    width: 100% !important;
    height: auto !important;
  }

  .mobile-quickbar {
    padding: 10px 8px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 12px #133f6420;
  }

  .quick-icons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin: 0;
  }

  .quick-icons a,
  .quick-icons button {
    min-height: 64px;
    border: 0;
    background: none;
    color: #36536c;
    text-decoration: none;
    padding: 8px 4px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.25;
    cursor: pointer;
  }

  .quick-icons i {
    width: 32px;
    height: 32px;
    margin: 0 auto 6px;
    border-radius: 50%;
    background: #1E6BB8;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-style: normal;
  }

  .quick-icons span {
    display: block;
    white-space: normal;
  }

  .business-cards {
    position: static !important;
    left: auto !important;
    top: auto !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    width: 100%;
  }

  .business-card {
    width: 100% !important;
    height: auto !important;
    min-height: 128px;
    border-radius: 14px;
    padding: 22px 18px;
    text-align: left;
  }

  .business-card h2 {
    font-size: 20px;
    line-height: 1.3;
  }

  .business-card p {
    display: block !important;
    font-size: 13px;
    margin-top: 8px;
    opacity: .92;
  }

  .core-card {
    border-radius: 12px;
    padding: 18px 16px;
    color: #fff;
    background: linear-gradient(155deg, #4A9BE8, #155A9C);
    box-shadow: 0 8px 16px #0c4c8c40;
  }

  .core-card h2 {
    font-size: 18px;
    text-align: left;
    margin: 0 0 8px;
  }

  .core-card p {
    font-size: 14px !important;
    font-weight: 600;
    text-align: left;
    line-height: 1.4 !important;
    margin: 0;
    padding: 10px 0 !important;
    border-top: 1px solid #ffffff3d;
  }

  .mobile-app-card {
    padding: 20px 16px 18px;
    text-align: center;
  }

  .mobile-app-card h2 {
    font-size: 18px !important;
    margin: 0 0 16px !important;
    white-space: normal !important;
  }

  .mobile-qr-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 0 0 16px !important;
  }

  .mobile-qr-row .download-qr:first-child {
    border-right: 1px solid #e8eef4;
    padding-right: 8px;
  }

  .mobile-app-card .download-qr img,
  .mobile-qr-row img {
    width: 96px !important;
    height: 96px !important;
    margin: 0 auto 8px;
  }

  .mobile-qr-row small {
    font-size: 13px;
  }

  .mobile-app-card .platform-button {
    margin-top: 4px;
    padding: 12px 16px;
    font-size: 14px;
    min-height: 44px;
  }

  .stats-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    max-width: none;
    margin: 0 !important;
  }

  .stats-grid article {
    height: auto;
    min-height: 96px;
    padding: 14px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
  }

  .stats-grid span {
    font-size: 28px;
  }

  .stats-grid b {
    font-size: 12px;
    font-weight: 600;
  }

  .partner-strip {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    height: auto;
    margin-top: 4px;
    padding: 12px 8px;
    gap: 12px 8px;
  }

  .partner-strip b,
  .partner-strip > div {
    white-space: normal;
    font-size: 12px;
    text-align: center;
  }

  .mobile-bottom-bar {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    min-height: 56px;
    height: auto;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid #e2eef7;
    gap: 8px;
  }

  .mobile-bottom-bar a,
  .mobile-bottom-bar button {
    min-height: 44px;
    border: 0;
    border-radius: 22px;
    background: linear-gradient(90deg, #0D3A6B, #1E6BB8);
    color: #fff;
    text-decoration: none;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 6px;
    text-align: center;
    line-height: 1.2;
    cursor: pointer;
  }

  .mobile-bottom-bar button {
    background: linear-gradient(90deg, #4A9BE8, #155A9C);
  }

  body {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }

  .detail-section {
    padding: 48px 16px;
    scroll-margin-top: calc(56px + env(safe-area-inset-top));
  }

  .section-heading {
    margin-bottom: 24px;
  }

  .section-heading h2 {
    font-size: clamp(24px, 7vw, 32px);
  }

  .section-heading p {
    font-size: 15px;
    line-height: 1.65;
  }

  .network-layout,
  .finance-layout,
  .about-grid,
  .platform-grid {
    grid-template-columns: 1fr !important;
    gap: 14px;
  }

  .network-photo {
    min-height: 220px;
  }

  .country-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .country-grid article,
  .platform-grid article {
    padding: 16px;
    min-height: 0;
  }

  .country-grid h3,
  .platform-grid h3 {
    font-size: 15px;
  }

  .country-grid p,
  .platform-grid p {
    font-size: 13px;
  }

  .platform-cta {
    align-items: stretch;
    flex-direction: column;
    padding: 20px;
    gap: 16px;
  }

  .platform-cta > div:last-child {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .platform-cta a,
  .platform-cta button,
  .section-button {
    min-height: 44px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .finance-flow article {
    padding: 16px;
  }

  .about-grid article {
    min-height: 0;
    padding: 22px;
  }

  .footer-inner {
    grid-template-columns: 1fr 1fr;
    gap: 24px 16px;
  }

  .footer-brand {
    grid-column: 1 / -1;
  }

  .footer-legal {
    flex-direction: column;
  }

  .site-footer {
    padding: 40px 16px calc(28px + env(safe-area-inset-bottom));
  }

  .download-modal {
    padding: 16px;
    align-items: flex-end;
  }

  .modal-panel {
    width: 100%;
    max-width: 480px;
    padding: 24px 18px calc(18px + env(safe-area-inset-bottom));
    border-radius: 16px 16px 0 0;
  }

  .modal-close {
    min-width: 44px;
    min-height: 44px;
  }

  .modal-qrs {
    gap: 20px;
  }

  .modal-qrs img {
    width: 120px;
    height: 120px;
  }
}

@media (min-width: 600px) and (max-width: 1023px) {
  .business-cards {
    grid-template-columns: 1fr 1fr !important;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .partner-strip {
    grid-template-columns: repeat(3, 1fr);
  }

  .platform-grid,
  .about-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  .hero {
    padding: 80px 28px 44px;
  }

  .content-sheet,
  .detail-section {
    padding-left: 24px;
    padding-right: 24px;
  }
}

@media (max-width: 379px) {
  .country-grid,
  .quick-icons {
    grid-template-columns: 1fr 1fr;
  }

  .login-pill-mobile {
    display: none;
  }

  .mobile-bottom-bar {
    grid-template-columns: 1fr;
  }

  .hero-copy h1,
  html[lang="en"] .hero-copy h1,
  html[lang="zh-CN"] .hero-copy h1 {
    font-size: 24px !important;
  }

  .mobile-app-card .download-qr img,
  .mobile-qr-row img,
  .modal-qrs img {
    width: 84px !important;
    height: 84px !important;
  }
}

@media (max-width: 1023px) and (orientation: landscape) {
  .hero {
    min-height: 0;
    padding: 48px 24px 28px;
  }

  .mobile-nav {
    width: min(360px, 70vw);
  }
}

@media (min-width: 1024px) {
  .mobile-bottom-bar,
  .mobile-quickbar,
  .core-card,
  .mobile-app-card,
  .hero-shortcuts,
  .mobile-account {
    display: none !important;
  }

  body {
    padding-bottom: 0;
  }
}

/* Section pages: absolute/cover images must not inherit global height:auto */
.spage-banner img,
.spage-feature img,
.spage-app-visual img {
  max-width: none;
  height: 100% !important;
}

@media (max-width: 1023px) {
  .inner-page .mobile-bottom-bar {
    grid-template-columns: 1fr 1fr;
  }

  .spage-body,
  .spage-app {
    padding-bottom: calc(100px + env(safe-area-inset-bottom));
  }

  /* Homepage phone/tablet: cut duplicate CTAs + empty height */
  body.home-landing .hero-shortcuts,
  body.home-landing .mobile-quickbar,
  body.home-landing .core-card {
    display: none !important;
  }

  body.home-landing .content-sheet {
    min-height: 0 !important;
    padding-bottom: 8px;
  }

  body.home-landing .mobile-app-card .platform-button {
    display: none !important;
  }

  body.home-landing {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }

  body.home-landing .mobile-bottom-bar {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }
}

