/*
 * Caihon v1.29 compatibility layer for the Minimal 4.0/_minimal50 visual system.
 * Business selectors and script-owned IDs remain untouched; this file only
 * bridges new/legacy pages onto the original template tokens and layout.
 */

/* Shared additions used by the v1.29-only module pages. */
.cardbuy-page .module-hero,
.cart-page .module-hero,
.daigua-page .module-hero,
.invite-page .module-hero,
.wx-guide-page .module-hero {
  margin-top: 16px;
}

.cardbuy-page .module-card,
.cart-page .module-card,
.daigua-page .module-card,
.invite-page .module-card,
.wx-guide-page .module-card,
.captcha-page .module-card,
.app-download-page .module-card {
  border-color: var(--line);
  background: rgba(255, 255, 255, .98);
  box-shadow: var(--shadow-md);
}

.cardbuy-page .mini-panel,
.cart-page .mini-panel,
.daigua-page .mini-panel,
.invite-page .mini-panel,
.wx-guide-page .mini-panel {
  border-color: var(--line);
  background: rgba(255, 255, 255, .98);
}

.cardbuy-page .form-control,
.invite-page .form-control {
  color: var(--ink);
  font-size: 15px;
}

.cardbuy-page .form-control::placeholder,
.invite-page .form-control::placeholder {
  color: #929e99;
}

.cardbuy-page .btn-primary,
.cart-page .btn-primary,
.invite-page .btn-primary,
.captcha-page .btn-primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.cardbuy-page .btn-primary:hover,
.cart-page .btn-primary:hover,
.invite-page .btn-primary:hover,
.captcha-page .btn-primary:hover,
.cardbuy-page .btn-primary:focus,
.cart-page .btn-primary:focus,
.invite-page .btn-primary:focus,
.captcha-page .btn-primary:focus {
  border-color: var(--brand-dark);
  background: var(--brand-dark);
  color: #fff;
}

.cardbuy-page :focus-visible,
.cart-page :focus-visible,
.daigua-page :focus-visible,
.invite-page :focus-visible,
.wx-guide-page :focus-visible,
.captcha-page :focus-visible,
.app-download-page :focus-visible,
.legacy-content-page :focus-visible,
.jump-page :focus-visible {
  outline: 3px solid rgba(21, 150, 107, .24);
  outline-offset: 3px;
}

/* APP download: both the signed iOS branch and the QR download branch. */
.app-download-page {
  min-height: 100vh;
  min-height: 100dvh;
}

.app-download-shell {
  width: min(780px, calc(100% - 32px));
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  margin: 0 auto;
  padding: 32px 0;
}

.app-download-card {
  width: 100%;
  padding: clamp(24px, 5vw, 42px);
  text-align: center;
}

.app-site-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  color: var(--ink) !important;
  font-size: 18px;
  font-weight: 900;
}

.app-site-brand img {
  width: 42px;
  height: 42px;
  padding: 4px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.app-download-page .page_header_upice,
.app-download-page .app-brief {
  display: grid;
  justify-items: center;
  gap: 12px;
  margin: 0 0 24px;
}

.app-download-page .app-icon,
.app-download-page .app-brief > .icon {
  width: 94px;
  height: 94px;
  display: block;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper-soft);
  box-shadow: var(--shadow-sm);
}

.app-download-page .app-icon img,
.app-download-page .app-brief > .icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.app-download-page .app-title,
.app-download-page .app-copy .name {
  margin: 0;
  color: var(--ink);
  font-size: clamp(24px, 5vw, 34px);
  font-weight: 900;
  letter-spacing: -.025em;
}

.app-download-page .app-subtitle,
.app-download-page .scan-tips,
.app-download-page .release-info,
.app-download-page .app-copyright {
  color: var(--muted);
  line-height: 1.75;
}

.app-download-page .page_content {
  margin-top: 16px;
}

.app-download-page .qui-button-main,
.app-download-page .actions button,
.app-download-page .ios span {
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  border: 1px solid var(--brand);
  border-radius: 12px;
  background: var(--brand);
  color: #fff !important;
  font-size: 16px;
  font-weight: 850;
  text-decoration: none;
  box-shadow: none;
}

.app-download-page .authorized_form_list {
  max-width: 520px;
  margin: 22px auto 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-soft);
  text-align: left;
}

.app-download-page .api_list {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.app-download-page .api_list li {
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
}

.app-download-page .control {
  margin-top: 10px;
  color: var(--brand-dark);
  font-weight: 800;
  cursor: pointer;
}

.app-download-page .app-brief {
  grid-template-columns: 94px minmax(0, 1fr) 132px;
  justify-items: stretch;
  align-items: center;
  text-align: left;
}

.app-download-page .app-copy {
  min-width: 0;
}

.app-download-page .qrcode {
  width: 132px;
  height: 132px;
  display: grid;
  place-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.app-download-page .qrcode canvas,
.app-download-page .qrcode img {
  max-width: 100%;
  height: auto;
}

/* Promotion and guide pages introduced by the newer release. */
.invite-page .invite-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 20px;
  align-items: start;
  margin-top: 18px;
}

.invite-page .invite-main,
.invite-page .stats-card {
  padding: 26px;
}

.invite-page .invite-tabs,
.daigua-page .guide-tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 22px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-soft);
}

.invite-page .invite-tabs > li,
.daigua-page .guide-tabs > li {
  float: none;
  flex: 1;
  margin: 0;
}

.invite-page .invite-tabs > li > a,
.daigua-page .guide-tabs > li > a {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  border: 0 !important;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 800;
}

.invite-page .invite-tabs > li.active > a,
.daigua-page .guide-tabs > li.active > a {
  background: #fff;
  color: var(--brand-dark);
  box-shadow: var(--shadow-sm);
}

.invite-page .reward-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 20px;
}

.invite-page .reward-option,
.invite-page .reward-list .list-group-item {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.invite-page .reward-option.active,
.invite-page .reward-list .list-group-item.active {
  border-color: rgba(21, 150, 107, .35);
  background: #edf8f3;
  color: var(--brand-dark);
}

.invite-page .invite-side-stack {
  display: grid;
  gap: 18px;
}

.invite-page .invite-help,
.invite-page .query-note,
.invite-page .invite-note {
  color: var(--muted);
  line-height: 1.72;
}

.invite-page .stats-head h2 {
  margin: 0 0 16px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
}

.invite-page .stats-columns {
  display: grid;
  grid-template-columns: 1.1fr .8fr 1fr;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--paper-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.invite-page .stats-scroll {
  height: 250px;
  margin-top: 8px;
}

.invite-page .stats-scroll img {
  width: 24px;
  height: 24px;
  margin-right: 6px;
  object-fit: contain;
  vertical-align: middle;
}

.daigua-page .guide-card {
  padding: 26px;
}

.daigua-page .guide-content {
  color: var(--muted);
  line-height: 1.75;
}

.daigua-page .guide-step {
  margin-bottom: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-soft);
}

.daigua-page .guide-step strong,
.daigua-page .guide-note strong {
  color: var(--ink);
}

.daigua-page .guide-alerts {
  display: grid;
  gap: 10px;
}

.daigua-page .guide-alert {
  padding: 14px 16px;
  border: 1px solid rgba(217, 144, 33, .22);
  border-radius: 12px;
  background: #fffaf1;
  color: #75501c;
}

.daigua-page .guide-alert.is-danger {
  border-color: rgba(220, 79, 104, .22);
  background: #fff6f7;
  color: #9c3148;
}

/* Unchanged v1.29 article/faka HTML receives the Minimal surface treatment. */
.legacy-content-page {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 34px 16px;
}

.legacy-content-page > br:first-child {
  display: none;
}

.legacy-content-page > .center-block {
  width: min(900px, 100%);
  padding: 0;
}

.legacy-content-page .block {
  overflow: hidden;
  border: 1px solid var(--line) !important;
  border-radius: var(--radius) !important;
  background: rgba(255, 255, 255, .98) !important;
  box-shadow: var(--shadow-md) !important;
}

.legacy-content-page .block-title {
  min-height: 70px;
  display: flex;
  align-items: center;
  padding: 20px 24px !important;
  border: 0 !important;
  border-bottom: 1px solid var(--line) !important;
  background: var(--paper-soft) !important;
}

.legacy-content-page .block-title h2 {
  margin: 0;
  color: var(--ink) !important;
  font-size: 21px;
  font-weight: 900;
}

.legacy-content-page .block-title + * {
  margin-top: 0;
}

.legacy-content-page .block > :not(.block-title) {
  margin-right: 24px;
  margin-left: 24px;
}

.legacy-content-page .breadcrumb {
  margin-top: 20px !important;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-soft);
}

.legacy-content-page .text-center h3 {
  margin-top: 26px;
  color: var(--ink);
  font-size: clamp(23px, 4vw, 31px);
  font-weight: 900;
  letter-spacing: -.02em;
  line-height: 1.35;
}

.legacy-content-page .text-muted {
  color: var(--muted) !important;
}

.legacy-content-page hr {
  border-top-color: var(--line);
}

.legacy-content-page .article-content {
  min-height: 180px;
  padding: 8px 0 20px;
  color: #34413c;
  font-size: 16px;
  line-height: 1.85;
  overflow-wrap: anywhere;
}

.legacy-content-page .article-content img,
.legacy-content-page .article-content video,
.legacy-content-page .article-content iframe {
  max-width: 100% !important;
}

.legacy-content-page .btn {
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 10px !important;
  font-weight: 800;
}

.legacy-content-page .btn-primary,
.legacy-content-page .btn-info {
  border-color: var(--brand) !important;
  background: var(--brand) !important;
  color: #fff !important;
}

.legacy-content-page .btn-default {
  border-color: var(--line-strong);
  background: #fff;
  color: var(--ink);
}

.article-list-legacy-page .form-group:first-of-type {
  margin-top: 22px !important;
}

.article-list-legacy-page .input-group-addon {
  border-color: var(--line-strong);
  background: var(--paper-soft);
  color: var(--brand-dark);
  font-weight: 800;
}

.article-list-legacy-page .form-control {
  min-height: 44px;
  border-color: var(--line-strong);
  box-shadow: none;
}

.article-list-legacy-page .table-responsive {
  margin-top: 18px !important;
  border: 0;
}

.article-list-legacy-page #msglist tr,
.article-list-legacy-page #msglist td {
  display: block;
}

.article-list-legacy-page #msglist tr {
  margin-bottom: 10px;
}

.article-list-legacy-page #msglist td {
  padding: 0 !important;
  border: 1px solid var(--line) !important;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.article-list-legacy-page #msglist a {
  min-height: 102px;
  padding: 17px 18px;
  color: var(--ink) !important;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}

.article-list-legacy-page #msglist a:hover,
.article-list-legacy-page #msglist a:focus {
  background: var(--paper-soft);
  transform: translateY(-1px);
}

.article-list-legacy-page #msglist b {
  max-width: 70%;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
}

.article-list-legacy-page #msglist p {
  color: var(--muted) !important;
  line-height: 1.65;
}

.faka-page .block {
  max-width: 880px;
  margin: 0 auto;
}

.faka-page .alert-info {
  margin-top: 22px !important;
  border-color: rgba(21, 150, 107, .2);
  border-radius: 11px;
  background: #edf8f3;
  color: #285a47;
}

.faka-page textarea.form-control {
  min-height: 300px;
  margin-top: 22px;
  padding: 16px;
  border-color: var(--line-strong);
  border-radius: 12px;
  background: #f9fbfa;
  color: var(--ink);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 14px;
  line-height: 1.65;
  resize: vertical;
  box-shadow: none;
}

.faka-page #saveas-bt {
  border-color: #dc4f68;
  background: #dc4f68;
}

/* Open-in-browser guidance, preserving all protocol fallback behavior. */
.jump-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  overflow: hidden;
}

.jump-page .top-bar-guidance {
  width: min(560px, 100%);
  height: auto;
  min-height: 250px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 38px !important;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .98) !important;
  color: var(--ink) !important;
  box-shadow: var(--shadow-md);
  font-size: 19px;
  font-weight: 850;
  line-height: 1.8;
}

.jump-page .top-bar-guidance p {
  margin: 4px 0;
}

.jump-page .icon-safari {
  width: 28px !important;
  height: 28px !important;
  margin: 0 5px !important;
  object-fit: contain;
}

.jump-page .app-download-tip {
  width: auto;
  max-width: min(560px, 100%);
  margin: 0;
  color: var(--muted);
  background: none;
  line-height: 1.65;
}

.jump-page .app-download-tip .guidance-desc {
  padding: 0;
  background: transparent;
}

.jump-page .app-download-btn {
  width: min(280px, 100%);
  height: 48px;
  line-height: 46px;
  margin: 0;
  border: 1px solid var(--brand);
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 850;
  cursor: pointer;
}

/* Keep the native 404 illustration, but match the Minimal color and depth. */
html.minimal-404-page-root,
body.minimal-404-page {
  background: #0b6f50 !important;
}

body.minimal-404-page::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url("background-lines.svg") center top / max(1280px, 100vw) auto no-repeat;
  filter: brightness(0) invert(1);
  opacity: .18;
  pointer-events: none;
}

body.minimal-404-page #wrap {
  z-index: 2;
}

body.minimal-404-page #wrap img {
  max-width: min(520px, 82vw);
  height: auto;
}

body.minimal-404-page #text a {
  color: #fff;
  text-underline-offset: 4px;
}

@media (max-width: 900px) {
  .invite-page .invite-layout {
    grid-template-columns: 1fr;
  }

  .invite-page .invite-side-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .app-download-page .app-brief {
    grid-template-columns: 80px minmax(0, 1fr);
  }

  .app-download-page .app-brief > .icon {
    width: 80px;
    height: 80px;
  }

  .app-download-page .qrcode {
    grid-column: 1 / -1;
    justify-self: center;
  }

  .invite-page .invite-side-stack {
    grid-template-columns: 1fr;
  }

  .invite-page .reward-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .cardbuy-page .minimal-shell,
  .cart-page .minimal-shell,
  .daigua-page .minimal-shell,
  .invite-page .minimal-shell,
  .wx-guide-page .minimal-shell {
    width: min(100% - 20px, 1180px);
  }

  .cardbuy-page .topbar,
  .cart-page .topbar,
  .daigua-page .topbar,
  .invite-page .topbar,
  .wx-guide-page .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .cardbuy-page .main-nav,
  .cart-page .main-nav,
  .daigua-page .main-nav,
  .invite-page .main-nav,
  .wx-guide-page .main-nav {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .app-download-shell {
    width: min(100% - 20px, 780px);
    padding: 10px 0;
  }

  .app-download-card {
    padding: 22px 18px;
  }

  .legacy-content-page {
    padding: 10px;
  }

  .legacy-content-page .block-title {
    min-height: 60px;
    padding: 17px 18px !important;
  }

  .legacy-content-page .block-title h2 {
    font-size: 18px;
  }

  .legacy-content-page .block > :not(.block-title) {
    margin-right: 18px;
    margin-left: 18px;
  }

  .article-list-legacy-page #msglist b,
  .article-list-legacy-page #msglist small {
    max-width: none;
    float: none !important;
  }

  .article-list-legacy-page #msglist small {
    display: block;
    margin-top: 4px;
  }

  .faka-page .form-group[style*="height"] {
    height: auto !important;
    min-height: 44px;
  }

  .faka-page .form-group[style*="height"] .pull-right {
    float: none !important;
    display: flex;
    gap: 8px;
  }

  .faka-page .form-group[style*="height"] .btn {
    flex: 1;
  }

  .jump-page {
    justify-content: flex-start;
    padding: 12px;
  }

  .jump-page .top-bar-guidance {
    min-height: 220px;
    padding: 26px 22px !important;
    font-size: 17px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cardbuy-page *,
  .cart-page *,
  .daigua-page *,
  .invite-page *,
  .wx-guide-page *,
  .captcha-page *,
  .app-download-page *,
  .legacy-content-page *,
  .jump-page * {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
