/* Load after page/vendor styles. Desktop typography stays in the original sheets.
   Font-size overrides deliberately win over legacy ID rules and inline styles;
   sizes use rem so browser text-size preferences and zoom still work. */
@media (max-width: 900px) {
    html {
        font-size: 100%;
    }

    body {
        --mobile-text: 1.0625rem;
        --mobile-secondary: .9375rem;
        --mobile-nav: .8125rem;
        font-size: var(--mobile-text);
        line-height: 1.5;
    }

    /* Main reading text, cards, tables and text actions. */
    body :where(p, li, td, dd, button, input, select, textarea,
        .um-item, .agency-header-home, .db-greeting, .db-notice-title,
        .db-shortcut, .db-notifications-all, .db-notification-status,
        .db-data-warning, .db-ranks-list li, .db-qr-status,
        .product-name, .product-mobile-price, .gh b, .brand-chip, .mb,
        .pop-desc, .pop-val, .pm-desc, .pm-sec-title,
        .agt .card, .agt .row, .agt .nm b, .agt .item, .agt .view,
        .agency-detail-grid dd, .agency-mobile-points,
        .agency-mobile-heading, .agency-total-card,
        .rp-tab, .rp-table, .rp-user-name, .rp-tx-note, .rp-network-name,
        .ob-table, .ob-order-link, .ob-order-dealer > strong,
        .ob-detail-fields, .ob-detail-note, .ob-create-total,
        .ob-mobile-orders-heading, .ob-mobile-orders-heading strong,
        .sf-plan, .sf-phase, .sf-item-title, .sf-item-price, .sf-item-reason,
        .sf-item-link, .sf-who, .sf-skin-type, .sf-prob-line, .sf-info-v,
        .sf-prob-story, .sf-prob-calm, .sf-prob-bridge, .sf-headsup,
        .sf-five-text, .sf-compare-title, .sf-crow, .sf-ctab-row,
        .sf-pick-item, .sf-mini-cell, .sf-cmp-row, .sf-photo-empty,
        .sf-card-title strong, .sf-sec-title,
        .sth-who strong, .sth-alert, .sth-empty,
        .nt-title, .nt-body, .nt-empty, .cu-item h3, .cu-empty,
        .message, .cu-msg, .msg, .toast, .profile-toast,
        .account-password-message, .intro-point, .auth-links,
        .form-row, .consent, .back-home, .link-text, .link-btn) {
        font-size: var(--mobile-text) !important;
        line-height: 1.5;
    }

    /* Compact rank card follows its own hierarchy from the dashboard design. */
    body.dashboard-page .db-rank-heading h2 {
        font-size: 1.0625rem !important;
        line-height: 1.3;
    }

    body.dashboard-page .db-rank-heading button,
    body.dashboard-page .db-rank-footer p {
        font-size: .75rem !important;
        line-height: 1.5;
    }

    body.dashboard-page .db-rank-heading button {
        min-height: 32px !important;
        white-space: nowrap;
    }

    body.dashboard-page .db-rank-footer {
        flex-wrap: nowrap;
    }

    /* Labels and supporting information keep a clear secondary hierarchy. */
    body :where(label, dt, small, time, th,
        .sub, .cd, .lb, .pt-lb, .pt-tier, .pt-next, .pt-num small,
        .rk-sub, .rk-no, .rk-nm small, .rk-pt, .parent-code-message, .f .msg,
        .db-agent-code, .db-period, .db-notice time, .db-ranks-note,
        .db-stats dt, .db-qr-code, .db-rank-balances dt,
        .prod-sku, .st, .gc, .pager, .pop-brand, .pop-lbl,
        .pm-bar-title, .pm-brand, .pm-lbl,
        .agt .subtitle, .agt .topbar, .agt .row.row-head, .agt .nm i,
        .agt .badge, .agt .status, .agt .pts small,
        .agency-tree-search-label, .agency-tree-search-status,
        .agency-detail-account, .agency-detail-grid dt, .agency-copy-status,
        .agency-mobile-label, .agency-mobile-points small,
        .rp-stat-label, .rp-count, .rp-network-code, .rp-network-level,
        .rp-network-hint, .rp-network-month-label, .rp-network-peak,
        .rp-network-chart-unit, .rp-network-chart-state, .rp-tag, .rp-src,
        .rp-pg, .rp-user-line, .rp-summary-item dt, .rp-tx-meta,
        .ob-muted, .ob-status, .ob-tag-pending, .ob-contact,
        .ob-owner-label, .ob-create-manual-code, .ob-detail-field-label,
        .points__unit, .ob-stat strong small,
        .sf-card-title small, .sf-foot-note, .sf-field-label, .sf-hint,
        .sf-error, .sf-chip, .sf-label, .sf-metric-head, .sf-metric-note,
        .sf-date, .sf-badge, .sf-fig, .sf-chead, .sf-cnote, .sf-print-brand,
        .sf-axis, .sf-prob-no, .sf-prob-code, .sf-badge-rec, .sf-item-step,
        .sf-info-l, .sf-prob-role, .sf-five-tag,
        .sth-sub, .sth-dot, .sth-field, .sth-count, .sth-pos, .sth-rank,
        .sth-pg, .sth-tile span, .sth-tile small, .sth-person-who p,
        .cu-note, .cu-count, .cu-badge, .nf-hero p, .nt-time,
        .field-help, .form-sub, .form-actions-note, .note, .intro-label,
        .auth-badge, .countdown, .profile-box p, .qr-box p) {
        font-size: var(--mobile-secondary) !important;
        line-height: 1.5;
    }

    body :is(h1, .sth-title, .form-title) {
        font-size: 1.5625rem !important;
        line-height: 1.3;
    }

    body :is(h2, .sec, .rp-title, .sth-h2, .otp-heading) {
        font-size: 1.3125rem !important;
        line-height: 1.3;
    }

    body :is(h3, h4, .rp-sec, .rk-nm b) {
        font-size: 1.1875rem !important;
        line-height: 1.3;
    }

    body :is(input, select, textarea) {
        font-size: var(--mobile-text) !important;
    }

    body :is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="range"]), select, button,
        .btn, .ob-button, .um-item, .brand-chip, .rp-tab, .sth-btn,
        .nf-hero-links a, .cu-pager a, .sth-pager a) {
        min-height: 44px;
        box-sizing: border-box;
    }

    body :is(button, .btn, .ob-button, .um-item, .brand-chip, .rp-tab,
        .nf-hero-links a, .cu-pager a, .sth-pager a) {
        height: auto;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    body :is(.db-qr-close, .rk-x, .account-password-x, .rp-modal-x,
        .rp-network-close, .pm-close, .pop-close, .cu-clear) {
        font-size: 1.5625rem !important;
        line-height: 1;
        min-width: 44px;
        min-height: 44px;
    }

    body :is(.agency-header-home, .um-item, .nf-hero-links a) {
        font-size: var(--mobile-text) !important;
    }

    .agency-header .hd-right {
        flex-shrink: 0;
    }

    .agency-header-home {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .agency-header .um-list {
        max-width: calc(100vw - 24px);
    }

    body .agency-bottom-item {
        font-size: var(--mobile-nav) !important;
        line-height: 1.25;
        min-height: 44px;
    }

    .agency-bottom-nav {
        height: auto;
        min-height: 72px;
    }

    .agency-bottom-label {
        white-space: normal;
        text-align: center;
        overflow-wrap: anywhere;
    }

    body.agency-bottom-layout {
        --agency-bottom-nav-space: calc(116px + env(safe-area-inset-bottom, 0px));
    }

    body :is(p, h1, h2, h3, h4, dd, .db-shortcut, .um-item, .product-name,
        .sf-info-v, .sf-item-title, .agency-detail-grid dd) {
        overflow-wrap: anywhere;
    }

    .db-notifications-head, .db-rank-footer, .rp-tool, .rp-pg,
    .auth-links, .form-row, .ref-actions {
        flex-wrap: wrap;
    }

    .db-notifications-head h2, .db-shortcut-group h2 {
        letter-spacing: normal;
    }

    .db-stats dd {
        font-size: 1.5625rem;
    }

    .db-stats > div {
        padding-left: 8px;
        padding-right: 8px;
    }

    .db-rank-heading {
        min-width: 0;
    }

    .rp-network-month-label, .rp-network-metrics, .sf-tabs {
        flex-wrap: wrap;
    }

    .password-wrap input {
        padding-right: 88px;
    }

    .password-toggle {
        max-width: 76px;
    }

    .agency-tree-search-controls input {
        min-width: 0;
    }

    .agency-detail-grid dd {
        min-width: 0;
    }
}
