/* Shared public UI corrections. Keep dark surfaces explicit: muted text is for light surfaces. */
body:has([data-public-header]), body:has(.auth-shell), body:has(.app), body.mg-security-page {
    --mg5-blue-2: #1769d5;
    --mg5-muted: #526780;
    --mg-muted: #526780;
    --home-muted: #526780;
    --muted: #526780;
    font-family: Vazirmatn, Tahoma, Arial, sans-serif !important;
}
body .mg-public-header, body .mg-public-footer, body .mg-public-footer *,
body .mg-mobile-drawer-v3, body .mg-mobile-drawer-v3 *, body .mg-ai, body .mg-ai *,
body:has([data-public-header]) :is(input, textarea, select, button),
.auth-shell :is(input, textarea, select, button), .app :is(input, textarea, select, button) {
    font-family: Vazirmatn, Tahoma, Arial, sans-serif !important;
}
body .mg-telegram-strip {
    background: linear-gradient(100deg, #07539f, #0868ad 52%, #0b61b4) !important;
}
body .mg-telegram-strip :is(strong, .mg-telegram-strip-action) { color: #fff !important; }
body .mg-telegram-strip-id { background: #084a82 !important; color: #fff !important; }
body .mg-public-auth, body .mg-buy-button,
body .mg-ai-head, body .mg-ai-form button, body .mg-ai-message.user .mg-ai-bubble,
body .mg-error-actions a:first-child {
    background: linear-gradient(110deg, #0e56b4, #1769d5) !important;
    color: #fff !important;
}
body .mg-public-auth { font-size: 12px !important; }
body .mg-header-search input { font-size: 14px !important; }
body .mg-header-search :is(input, textarea)::placeholder,
body:has([data-public-header]) :is(main input, main textarea)::placeholder,
.auth-shell :is(input, textarea)::placeholder, .app :is(input, textarea)::placeholder,
body .mg-ai-form textarea::placeholder { color: #526780 !important; opacity: 1 !important; }
body .mg-breadcrumb {
    color: #526780 !important;
    font-size: 12px !important;
    white-space: normal !important;
    flex-wrap: wrap;
    overflow-wrap: anywhere;
    line-height: 1.9;
}
body .mg-breadcrumb :is(span, b) { color: inherit !important; }
body .mg-search-suggestion-copy small { color: #526780 !important; font-size: 12px !important; }
body .mg-search-suggestion-copy strong { font-size: 14px !important; }
body :is(.mg-compare-head p, .mg-ai-compare-head p, .mg-ai-compare-query label small) {
    color: #526780 !important;
    font-size: 14px !important;
}

/* Homepage: legible copy and contrast across every stop of the gradients. */
body.moein-home :is(.hero-copy > p, .quick-tabs a, .quick-field small, .category-card p,
    .product-info > p, .partners-note, .mg-slider-controls > span, .mg-slider-controls > span span) {
    color: #526780 !important;
}
body.moein-home .hero-copy > p { font-size: 16px !important; }
body.moein-home .quick-field small { font-size: 12px !important; }
body.moein-home .quick-field select { font-size: 14px !important; }
body.moein-home .category-card b { color: #0e56b4 !important; }
body.moein-home .products-grid.is-image-grid .home-product .product-info > p {
    color: #526780 !important;
    font-size: 14px !important;
    line-height: 1.9 !important;
}
body.moein-home :is(.product-info > span, .hero-trust > span, .numbers-grid span,
    .article-grid article > span, .article-grid article > a, .partners-note,
    .mg-slider-controls > span, .mg-slider-controls > span span) { font-size: 12px !important; }
body.moein-home .blue-services {
    background: linear-gradient(135deg, #082d74, #104b99 52%, #153b91) !important;
}
body.moein-home .blue-services :is(.blue-heading .eyebrow, .blue-heading > p,
    .service-grid > div > span, .service-grid > div > h3, .service-grid > div > p) {
    color: #fff !important;
    opacity: 1 !important;
}
body.moein-home .blue-heading .eyebrow { background: #124280 !important; }
body.moein-home .service-grid > div,
body.moein-home .service-grid > div:hover { background: #123f80 !important; }
body.moein-home .service-grid > div > span { font-size: 12px !important; }
body.moein-home .service-grid > div > p { font-size: 15px !important; }
body.moein-home .final-cta p { font-size: 14px !important; }

/* Catalogue, product specifications and reviews. */
body :is(.promo-copy p, .mg-product-price small, .mg-product-price del,
    .mg-product-assurances span, .mg-product-fact small, .mg-purchase-profile-grid small,
    .mg-order-steps small, .mg-quick-compare small, .mg-review-summary small,
    .mg-review-card header small, .mg-reviews-empty) { color: #526780 !important; }
body .mg-product-about [class$="-v2-spec"] > small { color: #526780 !important; }
body :is(.mg-product-fact small, .mg-product-assurances span, .mg-quick-compare small,
    .mg-purchase-profile-grid small, .mg-order-steps small, .mg-review-summary small,
    .mg-review-card header small, .mg-verified-badge, .promo-copy p) { font-size: 12px !important; }
body :is(.mg-order-steps > div > b, .mg-review-avatar) { color: #0e56b4 !important; }
body :is(.mg-stars-static, .mg-review-rating) { color: #a55b00 !important; }
body :is(.mg-stars-static i, .mg-review-rating span) { color: #5e7186 !important; }
body .catalog-card .desc { font-size: 14px !important; }
body .catalog-card :is(.badge, .price small) { font-size: 12px !important; }

/* Magazine copy, metadata and captions, including editor-supplied opacity. */
body .mg-blog :is(.mg-blog-heading p, .mg-featured-copy p, .mg-post-card-body p,
    .mg-post-meta, .mg-post-meta span, .mg-result-count, .mg-newsletter p,
    .mg-related small, .mg-side-box p, .mg-faq p) { color: #526780 !important; }
body .mg-blog :is(.mg-post-meta, .mg-post-meta span, .mg-result-count, .mg-related small) {
    font-size: 12px !important;
}
body .mg-blog :is(.mg-post-card-body p, .mg-newsletter p, .mg-side-box p, .mg-faq p) {
    font-size: 14px !important;
}
body .mg-rich-content figcaption { color: #526780 !important; opacity: 1 !important; }
body .mg-rich-content video { color: #fff; }

/* Policy pages retain their blue hero with readable white text. */
body .terms-hero { background: linear-gradient(120deg, #104582, #165eaa) !important; }
body .terms-hero-copy > p { color: #fff !important; }
body .terms-kicker { color: #fff !important; background: #124280 !important; }
body .terms-highlights .highlight-icon { color: #075aaa !important; }
body .terms-shell :is(.terms-highlights p, .quick-steps span, .policy-heading p,
    .back-top, .terms-cta > div > span) { color: #526780 !important; }
body .terms-shell .back-top { font-size: 12px !important; }

/* Authentication and shared form controls. */
.auth-shell :is(.auth-separator, .remember) { color: #526780 !important; font-size: 12px !important; }
.auth-shell .sub { font-size: 14px !important; }
.auth-shell .field input { font-size: 16px !important; }
.auth-shell .otp-input { font-size: 25px !important; }
.auth-shell :is(.field label, .hint, .back, .alt-auth, .mobile-auth) { font-size: 14px !important; }
.auth-shell .mobile-auth small { color: #526780 !important; }
.auth-shell .btn { font-size: 14px !important; }
body .mg-public-footer :is(.mg-footer-benefits small, .mg-public-footer-bottom, .mg-trust-card small) {
    font-size: 12px !important;
    line-height: 1.9 !important;
}
body .mg-mobile-drawer-v3 :is(.mg-drawer-v3-title > span, .mg-drawer-v3-foot small) {
    font-size: 12px !important;
    color: #526780 !important;
}
body .mg-mobile-drawer-v3 .mg-drawer-v3-brand-copy small {
    color: #526780 !important;
    font-size: 12px !important;
    line-height: 1.7 !important;
}

/* Assistant: no clipped suggestion buttons and no fixed height fighting mobile insets. */
body .mg-ai-head :is(strong, small) { color: #fff !important; }
body .mg-ai-head small { font-size: 12px !important; }
body .mg-ai-avatar, body .mg-ai-head > button { flex-shrink: 0; }
body .mg-ai-head > div:nth-child(2) { min-width: 0; }
body .mg-ai-head > button { min-width: 40px; min-height: 40px; }
body .mg-ai-suggestions { flex-wrap: wrap; overflow-x: visible; flex-shrink: 0; }
body .mg-ai-suggestions button {
    flex: 0 1 auto;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    font-size: 12px !important;
}
body .mg-ai-actions { flex-wrap: wrap; flex-shrink: 0; }
body .mg-ai-actions button { font-size: 12px !important; }
body .mg-ai-notice { font-size: 12px !important; flex-shrink: 0; }
body .mg-ai-welcome p { font-size: 14px !important; }
body .mg-ai-form textarea { min-width: 0; font-size: 16px !important; }
body .mg-ai-form { flex-shrink: 0; }
body .mg-ai-form button { flex-shrink: 0; }
body :is(.mg-ai-foot, .mg-ai-time) { color: #526780 !important; font-size: 12px !important; }
body .mg-ai-foot { flex-shrink: 0; }
body .mg-ai-messages { min-height: 0; }

/* Customer dashboard and shared account pages. */
body .app { --green: #137a55; }
body .app .hero { background: linear-gradient(105deg, #1254ae, #1769d5 60%, #454fb9) !important; }
body .app .hero p { color: #fff !important; font-size: 14px !important; }
body .app :is(.side-title, .orders th, .footer) { color: #526780 !important; font-size: 12px !important; }
body .app :is(.menu a, .panel-sub, .stat small, .stat p, .status, .orders td, .wallet a) {
    font-size: 12px !important;
}
body .app .top-user > span:last-child { color: #526780 !important; }
body .app .wallet small { color: #fff !important; font-size: 12px !important; }
body :is(.wallet-head p, .wallet-table th, .wallet-page .empty) { color: #526780 !important; }
body .wallet-page :is(.wallet-head p, .wallet-table th, .wallet-table td, .empty, .tag, .notice, .rate-line) {
    font-size: 12px !important;
}
body .wallet-page .notice { overflow-wrap: anywhere; }
body .wallet-page .wallet-card :is(small, span) { color: #fff !important; font-size: 12px !important; }
body .wallet-page .tag.pending { color: #855700 !important; }
body:has([data-public-header]) main .field > label { font-size: 14px !important; }
body:has([data-public-header]) main .field :is(input:not([type="checkbox"]):not([type="radio"]),textarea,select) {
    font-size: 16px !important;
}
body:has([data-public-header]) .wrap :is(th, td, .status) { font-size: 12px !important; }
body:has([data-public-header]) .wrap th,
body:has([data-public-header]) .wrap td > span[style] { color: #526780 !important; }
body .checkout .summary { background: linear-gradient(145deg, #123f81, #1769d5) !important; }
body .checkout .summary :is(p, small) { color: #fff !important; }
body.mg-checkout-page .mg-checkout-progress { order: -2; }
body.mg-checkout-page .mg-checkout-progress > span { font-size: 12px !important; }
body.mg-checkout-page .mg-checkout-progress > span:not(.is-active) { color: #526780 !important; }
body.mg-checkout-page .mg-checkout-progress > span b { font-size: 12px !important; }
body.mg-checkout-page .mg-checkout-progress > span:not(.is-active) b { color: #526780 !important; }
body.mg-checkout-page .checkout .summary .badge { background: #124280 !important; font-size: 12px !important; }
body.mg-checkout-page .pricing-breakdown { background: #104582 !important; border-radius: 12px; }
body.mg-checkout-page .pricing-breakdown :is(.saving, .saving span, .saving b) { color: #d1ffea !important; }
body.mg-checkout-page .pricing-breakdown :is(.priority-row, .priority-row span, .priority-row b) { color: #fff1c2 !important; }
body.mg-checkout-page .priority-icon { background: #124280 !important; }
body.mg-checkout-page .priority-kicker { color: #855000 !important; font-size: 12px !important; }
body.mg-checkout-page .priority-check { accent-color: #0e56b4; }
body.mg-checkout-page .checkout form p { color: #526780 !important; font-size: 14px !important; }
body.mg-checkout-page .choice > b { color: #855000 !important; }
body.mg-checkout-page :is(.notice,.success,.error,.policy,.contact-help) { font-size: 12px !important; }

/* Focus must remain visible when existing styles remove the browser outline. */
body:has([data-public-header]) :is(a, button, input, textarea, select, summary):focus-visible,
.auth-shell :is(a, button, input, textarea, select):focus-visible,
.app :is(a, button, input, textarea, select):focus-visible {
    outline: 3px solid #0b4ca0 !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 5px #fff !important;
}
body:has([data-public-header]) :is(main [id], main h2, main h3) { scroll-margin-top: 165px; }
body.mg-security-page .box { box-sizing: border-box; overflow-wrap: anywhere; }

@media (max-width: 600px) {
    body .category-nav { flex-wrap: wrap !important; overflow: visible !important; }
    body .category-nav a { flex: 0 1 auto !important; white-space: normal !important; }
    body.mg-checkout-page .mg-checkout-progress > span { flex-direction: column; text-align: center; }
    body .mg-header-search input,
    body:has([data-public-header]) main :is(input:not([type="checkbox"]):not([type="radio"]), textarea, select),
    .app :is(input, textarea, select) { font-size: 16px !important; }
    body .mg-ai-panel {
        inset: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
            max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)) !important;
        width: auto !important;
        height: auto !important;
        max-height: none !important;
    }
    body .mg-ai-head { min-height: 78px; }
    body .mg-ai-welcome { padding: 12px 8px; }
}
@media (prefers-reduced-motion: reduce) {
    body .mg-ai-panel, body.moein-home .service-grid > div { animation: none !important; transition: none !important; }
    body .mg-ai-messages { scroll-behavior: auto; }
}
