/*
 * Targeted visual polish for the six public entry pages:
 * /ddt, /gm2, /money, /temp-redeem, /tutorial, /ldxp-shop.
 * Keep this layer visual-only. Do not change business API contracts here.
 */

body.user-entry-page {
  overflow-x: clip;
}

body.user-entry-page :is(h1, h2, h3, p, a, button, label, strong, span, small, input, select, textarea) {
  letter-spacing: 0 !important;
}

body.user-entry-page .page-shell,
body.user-entry-page .page,
body.user-entry-page .entry-frame,
body.user-entry-page .container {
  box-sizing: border-box;
  min-width: 0 !important;
}

body.user-entry-page .entry-top-nav-shell,
body.user-entry-page .entry-top-nav-brand,
body.user-entry-page .entry-top-nav-copy,
body.user-entry-page .entry-top-nav-links {
  min-width: 0 !important;
}

body.user-entry-page .entry-top-nav-copy strong,
body.user-entry-page .entry-top-nav-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
}

body.user-entry-page :is(.entry-hero, .hero, .title, .shop-hero, .money-dashboard) {
  min-width: 0 !important;
}

body.user-entry-page :is(.hero p, .title p, .entry-hero p, .section-copy, .field-note, .dispatch-field-note, .notice span, .entry-risk-card, .entry-quick-card) {
  overflow-wrap: anywhere;
}

body.user-entry-page :is(input, select, textarea, button, .entry-url-action, .hero-link, .hero-link-secondary, .notice-link, .notice-btn) {
  max-width: 100%;
}

/* GM page: keep the real work area before optional helper and purchase surfaces. */
body.gm2-titanium-surface .gm2-main-workbench {
  grid-auto-flow: row;
}

body.gm2-titanium-surface .gm2-main-workbench > * {
  min-width: 0 !important;
}

@media (min-width: 1181px) {
  body.user-entry-page.apple-nav-theme.black-gold-entry.op-entry-redesign.gm2-titanium-surface .gm2-main-workbench {
    grid-template-columns: minmax(300px, .9fr) minmax(520px, 1.45fr) minmax(260px, .76fr) !important;
  }

  body.user-entry-page.apple-nav-theme.black-gold-entry.op-entry-redesign.gm2-titanium-surface .gm2-runtime-strip {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.05fr) minmax(0, 1.35fr) minmax(0, 1fr) minmax(92px, auto) !important;
  }

  body.user-entry-page.apple-nav-theme.black-gold-entry.op-entry-redesign.gm2-titanium-surface .ldxp-shop-ad {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 260px) !important;
  }

  body.user-entry-page.apple-nav-theme.black-gold-entry.op-entry-redesign.gm2-titanium-surface .gm2-service-column,
  body.user-entry-page.apple-nav-theme.black-gold-entry.op-entry-redesign.gm2-titanium-surface .gm2-wa-tool-dock,
  body.user-entry-page.apple-nav-theme.black-gold-entry.op-entry-redesign.gm2-titanium-surface .grade-tool-launch-row,
  body.user-entry-page.apple-nav-theme.black-gold-entry.op-entry-redesign.gm2-titanium-surface .ldxp-shop-ad-actions {
    max-width: 100% !important;
    min-width: 0 !important;
  }
}

body.gm2-titanium-surface .gm2-console-panel {
  order: 1 !important;
}

body.gm2-titanium-surface .gm2-catalog-panel {
  order: 2 !important;
}

body.gm2-titanium-surface .gm2-console-side {
  order: 3 !important;
}

body.gm2-titanium-surface .gm2-shop-frame,
body.gm2-titanium-surface .gm2-shop-frame iframe {
  display: none !important;
}

body.gm2-titanium-surface .gm2-shop-note {
  border-color: rgba(172, 122, 41, .24) !important;
  color: #4d3415 !important;
  -webkit-text-fill-color: #4d3415 !important;
  background: rgba(255, 248, 232, .9) !important;
}

body.gm2-titanium-surface .gm2-shop-note::before {
  content: "购买预览改为按钮入口，避免第三方页面拦截影响主操作。";
  display: block;
  margin-bottom: 6px;
  color: #6a4210;
  -webkit-text-fill-color: #6a4210;
  font-weight: 850;
}

body.gm2-titanium-surface .gm2-runtime-strip,
body.gm2-titanium-surface .gm2-target-dock,
body.gm2-titanium-surface .gm2-wa-panel {
  max-width: 100%;
}

/* Money page: remove the mobile overflow created by fixed grid columns. */
body.money-wa-theme .money-dashboard,
body.money-wa-theme .money-cockpit-grid,
body.money-wa-theme .money-form-stack,
body.money-wa-theme :is(#envSection, #pointsSection, #materialSection, #blindBoxSection, .money-side-panel, .money-side-rail) {
  max-width: 100% !important;
  min-width: 0 !important;
}

body.money-wa-theme .money-hero-alerts .notice {
  color: #2f261a !important;
  -webkit-text-fill-color: #2f261a !important;
}

body.money-wa-theme .money-form-stack :is(input, select, textarea) {
  color: #fff8e6;
}

/* Tutorial page: force normal horizontal Chinese text in the hero. */
body.tutorial-wa-theme #entryTop :is(.hero-copy, h1, p, .hero-actions, .hero-route) {
  writing-mode: horizontal-tb !important;
  text-orientation: mixed !important;
  white-space: normal !important;
  word-break: keep-all !important;
}

body.tutorial-wa-theme #entryTop h1 {
  overflow-wrap: normal !important;
}

body.tutorial-wa-theme :is(.step, .media, .media-frame) {
  max-width: 100% !important;
  min-width: 0 !important;
}

body.tutorial-wa-theme .media-frame img {
  max-width: 100% !important;
}

body.tutorial-wa-theme .media-point {
  max-width: min(260px, calc(100vw - 72px));
}

/* Download page: keep URLs and client cards from pushing the viewport. */
body.ddt-wa-theme .client-download-stage {
  isolation: isolate;
}

body.ddt-wa-theme .entry-url-section {
  overflow: hidden;
}

body.ddt-wa-theme .ddt-top-flash,
body.ddt-wa-theme .ddt-top-url-section {
  margin: 0 0 clamp(14px, 2.2vw, 22px);
}

body.ddt-wa-theme .ddt-top-url-section {
  background:
    linear-gradient(145deg, rgba(255, 252, 245, .94), rgba(236, 232, 224, .88)) !important;
  color: #1c1d20 !important;
}

body.ddt-wa-theme .entry-url-action {
  min-width: 0 !important;
}

body.ddt-wa-theme .client-platform-url code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Temp redeem: keep the token card from competing with the main form on narrow screens. */
body.temp-redeem-wa .hero-token-code,
body.temp-redeem-wa .reward-preview-table {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Purchase page: reduce overclaiming visuals and keep the iframe as optional. */
body.shop-wa-theme .shop-proof small,
body.shop-wa-theme .shop-flow-list span,
body.shop-wa-theme .shop-warning span {
  color: rgba(60, 48, 34, .78) !important;
  -webkit-text-fill-color: rgba(60, 48, 34, .78) !important;
}

body.shop-wa-theme .shop-preview {
  margin-top: clamp(18px, 3vw, 28px);
}

body.shop-wa-theme .shop-preview-primary {
  color: #1d1d1f !important;
  margin-top: 0 !important;
}

body.shop-wa-theme .shop-preview-primary summary strong {
  color: #1d1d1f !important;
  -webkit-text-fill-color: #1d1d1f !important;
}

body.shop-wa-theme .shop-preview-primary summary span {
  color: #4a4238 !important;
  -webkit-text-fill-color: #4a4238 !important;
}

body.shop-wa-theme .shop-preview-primary .shop-preview-actions span {
  color: rgba(255, 244, 214, .86) !important;
  -webkit-text-fill-color: rgba(255, 244, 214, .86) !important;
}

body.shop-wa-theme .shop-preview-primary .shop-frame-wrap,
body.shop-wa-theme .shop-preview-primary .shop-frame-shell,
body.shop-wa-theme .shop-preview-primary iframe {
  min-height: clamp(720px, 78vh, 1040px) !important;
}

body.shop-wa-theme #shopPreviewDetails:not([open]) .shop-preview-body {
  display: none !important;
}

@media (max-width: 760px) {
  html,
  body.user-entry-page {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden !important;
  }

  body.user-entry-page .page-shell,
  body.user-entry-page .page,
  body.user-entry-page .entry-frame,
  body.user-entry-page .container,
  body.user-entry-page .card.entry-frame,
  body.user-entry-page .page.entry-frame,
  body.user-entry-page .shop-page.entry-frame,
  body.user-entry-page .tutorial-page.entry-frame,
  body.user-entry-page .gm2-wa-workbench,
  body.user-entry-page .op-c-page-shell {
    width: 100% !important;
    max-width: 100% !important;
    margin-inline: 0 !important;
  }

  body.user-entry-page .page-shell {
    padding-inline: 8px !important;
  }

  body.user-entry-page .page {
    padding-inline: 0 !important;
  }

  body.user-entry-page .entry-top-nav-mount {
    position: sticky;
    top: calc(env(safe-area-inset-top) + 6px);
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 0 10px !important;
    padding-inline: 0 !important;
  }

  body.user-entry-page .entry-top-nav-shell {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
    min-height: 0 !important;
    gap: 9px !important;
    padding: 10px !important;
    border-radius: 18px !important;
  }

  body.user-entry-page .entry-top-nav-brand {
    width: 100%;
    gap: 9px !important;
  }

  body.user-entry-page .entry-top-nav-mark {
    width: 38px !important;
    min-width: 38px !important;
    height: 38px !important;
    border-radius: 14px !important;
    font-size: 10px !important;
  }

  body.user-entry-page .entry-top-nav-copy strong {
    font-size: 15px !important;
    line-height: 1.15 !important;
  }

  body.user-entry-page .entry-top-nav-copy small {
    max-width: 100%;
    font-size: 11px !important;
    line-height: 1.25 !important;
  }

  body.user-entry-page .entry-top-nav-links {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: flex-start !important;
    width: 100%;
    gap: 7px !important;
    overflow: visible !important;
    padding: 0;
    scrollbar-width: none;
  }

  body.user-entry-page .entry-top-nav-links::-webkit-scrollbar {
    display: none;
  }

  body.user-entry-page .entry-top-nav-link {
    flex: 1 1 calc(33.333% - 8px) !important;
    justify-content: center !important;
    min-width: 0 !important;
    min-height: 38px !important;
    gap: 6px !important;
    padding: 0 8px !important;
    border-radius: 999px !important;
  }

  body.user-entry-page .entry-top-nav-badge {
    display: none !important;
  }

  body.user-entry-page .entry-top-nav-text {
    max-width: 100%;
    overflow: hidden;
    font-size: 12px !important;
    line-height: 1 !important;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.user-entry-page :is(.entry-hero, .hero, .title, .shop-hero) {
    border-radius: 18px !important;
  }

  body.user-entry-page :is(h1, .hero h1, .title h1, .shop-hero h1) {
    font-size: clamp(30px, 10vw, 42px) !important;
    line-height: 1.12 !important;
  }

  body.gm2-titanium-surface .gm2-runtime-strip {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0 !important;
    overflow: hidden !important;
  }

  body.gm2-titanium-surface .gm2-runtime-cell {
    min-width: 0 !important;
    padding: 9px 10px !important;
  }

  body.gm2-titanium-surface .gm2-runtime-cell:last-child {
    grid-column: 1 / -1;
  }

  body.gm2-titanium-surface .gm2-main-workbench,
  body.gm2-titanium-surface .gm2-console-layout,
  body.gm2-titanium-surface .gm2-target-dock-grid,
  body.gm2-titanium-surface .grid {
    grid-template-columns: 1fr !important;
  }

  body.gm2-titanium-surface .gm2-main-workbench {
    gap: 14px !important;
  }

  body.gm2-titanium-surface .gm2-wa-tool-dock.grade-tool-banner {
    margin-top: 0 !important;
  }

  body.money-wa-theme .money-dashboard,
  body.money-wa-theme .money-cockpit-grid,
  body.money-wa-theme .money-form-stack,
  body.money-wa-theme .dispatch-grid,
  body.money-wa-theme .money-hero-alerts,
  body.money-wa-theme #pointsSection .dispatch-preset-row {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
  }

  body.money-wa-theme .money-dashboard {
    padding: 18px !important;
    border-radius: 18px !important;
  }

  body.money-wa-theme .money-command-card,
  body.money-wa-theme sl-card.money-command-card {
    width: 100% !important;
    min-width: 0 !important;
  }

  body.money-wa-theme :is(.dispatch-field-2, .dispatch-field-4, .dispatch-field-6, .dispatch-field-12) {
    grid-column: 1 / -1 !important;
    min-width: 0 !important;
  }

  body.money-wa-theme .inline-controls {
    justify-content: flex-start !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  body.money-wa-theme .inline-controls .checkbox-wrap {
    flex-wrap: wrap;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  body.money-wa-theme #pointsSection .dispatch-preset-row > * {
    width: 100% !important;
    grid-column: 1 / -1 !important;
  }

  body.temp-redeem-wa .hero.entry-hero {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  body.temp-redeem-wa .temp-card-visual {
    min-height: 150px !important;
  }

  body.temp-redeem-wa .hero-token {
    width: 100% !important;
  }

  body.ddt-wa-theme .client-platform-grid,
  body.ddt-wa-theme .ddt-content-grid,
  body.ddt-wa-theme .promo-feature,
  body.ddt-wa-theme .promo-feature-links,
  body.ddt-wa-theme .entry-url-summary {
    grid-template-columns: 1fr !important;
  }

  body.ddt-wa-theme .ddt-side-column {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  body.ddt-wa-theme .client-platform-card {
    min-height: 0 !important;
  }

  body.ddt-wa-theme .promo-feature-price {
    grid-template-columns: 1fr !important;
  }

  body.user-entry-page.apple-nav-theme.black-gold-entry.op-entry-redesign.tutorial-wa-theme #entryTop.hero.entry-hero,
  body.tutorial-wa-theme #entryTop.hero.entry-hero {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 18px !important;
    min-height: 0 !important;
    padding: 26px 22px !important;
  }

  body.user-entry-page.apple-nav-theme.black-gold-entry.op-entry-redesign.tutorial-wa-theme #entryTop .hero-copy,
  body.tutorial-wa-theme #entryTop .hero-copy {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    grid-column: 1 / -1 !important;
    padding-left: 0 !important;
  }

  body.user-entry-page.apple-nav-theme.black-gold-entry.op-entry-redesign.tutorial-wa-theme #entryTop .hero-emblem,
  body.tutorial-wa-theme #entryTop .hero-emblem {
    display: none !important;
  }

  body.user-entry-page.apple-nav-theme.black-gold-entry.op-entry-redesign.tutorial-wa-theme #entryTop h1,
  body.tutorial-wa-theme #entryTop h1 {
    width: 100% !important;
    max-width: 100% !important;
    font-size: clamp(38px, 13vw, 52px) !important;
    line-height: 1.08 !important;
  }

  body.user-entry-page.apple-nav-theme.black-gold-entry.op-entry-redesign.tutorial-wa-theme #entryTop .hero-copy > p,
  body.tutorial-wa-theme #entryTop .hero-copy > p {
    width: 100% !important;
    max-width: 100% !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
  }

  body.user-entry-page.apple-nav-theme.black-gold-entry.op-entry-redesign.tutorial-wa-theme #entryTop .hero-actions,
  body.tutorial-wa-theme #entryTop .hero-actions {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  body.user-entry-page.apple-nav-theme.black-gold-entry.op-entry-redesign.tutorial-wa-theme #entryTop .hero-link,
  body.user-entry-page.apple-nav-theme.black-gold-entry.op-entry-redesign.tutorial-wa-theme #entryTop .hero-link-secondary,
  body.tutorial-wa-theme #entryTop .hero-link,
  body.tutorial-wa-theme #entryTop .hero-link-secondary {
    width: 100% !important;
    min-width: 0 !important;
  }

  body.user-entry-page.apple-nav-theme.black-gold-entry.op-entry-redesign.tutorial-wa-theme #entryTop .hero-route,
  body.tutorial-wa-theme #entryTop .hero-route {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    max-width: 100% !important;
    grid-column: 1 / -1 !important;
    gap: 10px !important;
  }

  body.user-entry-page.apple-nav-theme.black-gold-entry.op-entry-redesign.tutorial-wa-theme #entryTop .route-node:not(:last-child)::after,
  body.tutorial-wa-theme #entryTop .route-node:not(:last-child)::after {
    display: none !important;
  }

  body.tutorial-wa-theme .step {
    grid-template-columns: 1fr !important;
  }

  body.shop-wa-theme .shop-hero,
  body.shop-wa-theme .shop-main-grid,
  body.shop-wa-theme .shop-next-grid,
  body.shop-wa-theme .shop-proof-row,
  body.shop-wa-theme .shop-domain-row,
  body.shop-wa-theme .shop-actions,
  body.shop-wa-theme .shop-link-copy,
  body.shop-wa-theme .shop-preview-actions,
  body.shop-wa-theme .shop-preview-buttons {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  body.shop-wa-theme .shop-visual {
    display: none !important;
  }
}
