/* Phone layout for the account area and CMS pages: stacked cards, big touch targets, no sideways scrolling.
   Phones only (<= 767px); desktop is untouched. Loaded in the page head, i.e. BEFORE account.css, so these rules
   use a `body` prefix (and !important where account.css already does) to win. */
@media (max-width: 767px) {

    /* ---- page frame ---- */
    html { -webkit-text-size-adjust: 100%; }
    body { overflow-x: hidden; }
    /* the tab bar already shows the bag count, so the header total only squeezes the logo */
    .ast-woo-header-cart-info-wrap, .ast-woo-header-cart-total { display: none !important; }
    body #content .ast-container { padding-left: 0; padding-right: 0; }
    html body #primary { padding: 0 16px; margin: 0; max-width: 100% !important; box-sizing: border-box; }
    body .site-content .ast-container .entry-content, body .woocommerce { min-width: 0; }

    /* ---- inputs: 16px stops iOS zooming in, 48px tall for thumbs ---- */
    body input[type="text"], body input[type="email"], body input[type="tel"], body input[type="search"], body input[type="password"],
    body input[type="number"], body select, body textarea,
    body .woocommerce-MyAccount-content input.input-text, body .woocommerce-MyAccount-content select, body .woocommerce-MyAccount-content textarea {
        font-size: 16px !important; min-height: 48px; border-radius: 10px; }
    body textarea { min-height: 96px; padding-top: 12px; }
    body .woocommerce-MyAccount-content input.input-text, body .woocommerce-MyAccount-content select, body .woocommerce-MyAccount-content textarea, body .acc-field input, body .acc-field textarea { color: var(--ink, #0f0f10); }
    body .acc-btn, body .woocommerce-MyAccount-content .button, body .woocommerce-MyAccount-content button[type="submit"] {
        width: 100%; height: auto; min-height: 50px; padding-top: 12px; padding-bottom: 12px; border-radius: 12px !important; font-size: 13.5px; letter-spacing: .06em; line-height: 1.25; text-align: center; }
    body .acc-btn-inline { width: 100%; }
    body .acc-check { align-items: flex-start; line-height: 1.45; font-size: 14px; }
    body .acc-check input, body .pf-switch input { min-width: 22px; min-height: 22px; }

    /* ---- signed out: sign-in card fills the screen like an app login ---- */
    body .acc-auth { padding: 6px 0 12px; }
    body .acc-card { padding: 22px 4px 18px; border: 0; box-shadow: none; background: transparent; border-radius: 0; }
    body .acc-title { font-size: 26px; }
    body .acc-sub { font-size: 15px; }
    body .acc-field input { height: 52px; }
    body .acc-perks { font-size: 14px; gap: 10px; margin-top: 18px; }
    body .acc-perks li { line-height: 1.45; padding-left: 26px; }
    body .acc-perks li::before { top: 2px; }

    /* ---- signed in: one column that is allowed to shrink (a plain 1fr made the page twice as wide as the screen) ---- */
    html body.woocommerce-account .woocommerce:has(.woocommerce-MyAccount-navigation) { grid-template-columns: minmax(0, 1fr); gap: 12px; padding-top: 10px; }
    html body .woocommerce-MyAccount-navigation { margin: 0 -16px; padding: 0 16px; width: auto !important; }
    body .woocommerce-MyAccount-navigation ul { padding: 4px; gap: 6px; border-radius: 14px; max-width: 100%; box-sizing: border-box; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; }
    body .woocommerce-MyAccount-navigation li { flex: none; scroll-snap-align: start; }
    body .woocommerce-MyAccount-navigation a { padding: 10px 14px; border-radius: 10px; font-size: 14px; }

    /* ---- dashboard ---- */
    body .pf { grid-template-columns: minmax(0, 1fr); gap: 14px; margin-top: 6px; }
    body .pf-card { position: static; display: grid; grid-template-columns: 56px minmax(0, 1fr); column-gap: 14px; row-gap: 0; align-items: center; text-align: left; padding: 16px; border-radius: 16px; }
    body .pf-avatar { grid-row: 1 / span 3; width: 56px; height: 56px; margin: 0; font-size: 19px; }
    body .pf-name { font-size: 18px; margin: 0; text-align: left; }
    body .pf-mail { font-size: 13px; margin: 2px 0 0; text-align: left; overflow-wrap: anywhere; }
    body .pf-since { grid-column: 2; margin: 2px 0 0; font-size: 12px; text-align: left; }
    body .pf-stats { grid-column: 1 / -1; margin: 14px 0 12px; }
    body .pf-jump { grid-column: 1 / -1; display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 2px; scrollbar-width: none; text-align: center; grid-template-columns: none; }
    body .pf-jump::-webkit-scrollbar { display: none; }
    body .pf-jump a { flex: none; padding: 9px 14px; border: 1px solid var(--line, #e6e6e6); border-radius: 999px; font-size: 13.5px; font-weight: 600; color: var(--ink, #0f0f10); text-decoration: none; background: #fff; }
    body .pf-signout { grid-column: 1 / -1; margin-top: 12px; padding: 13px; border-radius: 12px; }
    body .pf-greet, body .pf-main .pf-greet { font-size: 22px; }
    body .pf-main { gap: 14px; }

    /* panels read as grouped app lists */
    body .acc-panel { border-radius: 16px; margin-bottom: 0; }
    body .acc-panel > header, body .pf-main .acc-panel > header { padding: 14px 16px; }
    body .pf-addr, body .pf-form { padding: 14px 16px 18px; }
    body .pf-row, body .pf-addr { grid-template-columns: minmax(0, 1fr); }

    /* order in progress: thumbnails and text on one line, status chip below, never a one-letter-wide column */
    body .acc-track { padding: 16px; border-radius: 16px; box-shadow: 3px 3px 0 var(--blue-soft, #e8f0ff); }
    body .acc-track-top { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "text text" "thumbs pill"; gap: 12px; align-items: center; }
    body .acc-track-top > .acc-track-text { grid-area: text; }
    body .acc-track-top > .acc-track-thumbs { grid-area: thumbs; }
    body .acc-track-top > .acc-pill { grid-area: pill; justify-self: end; }
    body .acc-track-thumbs img { width: 44px; height: 55px; }
    body .acc-track-text strong { font-size: 15px; overflow-wrap: anywhere; }
    body .acc-steps li { font-size: 11.5px; }

    /* order rows (dashboard and orders list): thumbnails | number + date | total, status chip underneath */
    body .acc-order { display: grid; grid-template-columns: auto minmax(0, 1fr) auto !important; grid-template-areas: "th num total" "th meta meta" "th pill pill"; gap: 3px 12px; align-items: center; padding: 14px 16px; min-height: 64px; }
    body .acc-order:not(:has(.acc-order-thumbs)) { grid-template-columns: minmax(0, 1fr) auto !important; grid-template-areas: "num total" "meta meta" "pill pill"; }
    body .acc-order > .acc-order-thumbs { grid-area: th; }
    body .acc-order > .acc-order-main { display: contents; }
    body .acc-order > .acc-order-main strong { grid-area: num; font-size: 16px; }
    body .acc-order > .acc-order-main small { grid-area: meta; }
    body .acc-order > .acc-pill { grid-area: pill !important; justify-self: start; margin-top: 4px; }
    body .acc-order > .acc-order-total { grid-area: total !important; grid-column: auto !important; min-width: 0; text-align: right; font-size: 15px; white-space: nowrap; }
    body .acc-order > .acc-chev { display: none; }
    body .acc-order-thumbs img { width: 40px; height: 50px; }
    body .acc-order-thumbs img:nth-child(n+3) { display: none; }
    body .acc-order:active { background: #f3f4f6; }
    body .acc-stat-n { font-size: 18px !important; }

    /* ---- one order ---- */
    body .acc-ohead { margin-bottom: 14px; }
    body .acc-ohead h1 { font-size: 22px; }
    body .woocommerce-MyAccount-content h2, body .woocommerce-order-details__title { font-size: 17px; }
    /* item table becomes a card list: no sideways scrolling, totals stay visible */
    body .woocommerce-MyAccount-content table.woocommerce-table, body .woocommerce-MyAccount-content table.shop_table { display: block; border-radius: 16px; margin-bottom: 18px; }
    body .woocommerce-table--order-details thead { display: none; }
    body .woocommerce-table--order-details tbody, body .woocommerce-table--order-details tfoot { display: block; }
    body .woocommerce-table--order-details tr { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
    body .woocommerce-table--order-details tbody tr { padding: 2px 0; }
    body .woocommerce-table--order-details tr > th, body .woocommerce-table--order-details tr > td { padding: 11px 16px; border: 0 !important; }
    body .woocommerce-table--order-details tbody tr, body .woocommerce-table--order-details tfoot tr { border-bottom: 1px solid var(--line, #e6e6e6); }
    body .woocommerce-table--order-details tfoot tr:last-child { border-bottom: 0; }
    body .woocommerce-table--order-details td.product-name { flex: 1; min-width: 0; }
    body .woocommerce-table--order-details td.product-total { flex: none; white-space: nowrap; font-weight: 600; }
    body .woocommerce-table--order-details tfoot th { width: auto; flex: none; }
    body .woocommerce-table--order-details tfoot td { text-align: right; min-width: 0; overflow-wrap: anywhere; }
    body .woocommerce-table--order-details tfoot tr.acc-total-row { background: #fafafa; }
    body .woocommerce-table--order-details tfoot tr.acc-total-row th, body .woocommerce-table--order-details tfoot tr.acc-total-row td { background: none; }
    body .woocommerce-MyAccount-content .woocommerce-columns--addresses { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    body .woocommerce-MyAccount-content address { border-radius: 14px; overflow-wrap: anywhere; }
    body .acc-thumb { width: 48px; height: 60px; }

    /* ---- addresses and account details forms ---- */
    body .woocommerce-MyAccount-content .woocommerce-Addresses { grid-template-columns: minmax(0, 1fr); }
    body .woocommerce-MyAccount-content form .form-row-first, body .woocommerce-MyAccount-content form .form-row-last { width: 100% !important; margin-left: 0; display: block; }
    body .woocommerce-MyAccount-content fieldset { padding: 14px; border-radius: 14px; }
    body .woocommerce-MyAccount-content .woocommerce-Address-title { display: flex; flex-direction: column; align-items: flex-start; gap: 0; margin: 0 0 6px; }
    body .woocommerce-MyAccount-content .woocommerce-Address-title h2 { margin: 0 !important; font-size: 17px; text-align: left; float: none; }
    body .woocommerce-MyAccount-content .woocommerce-Address-title .edit { padding: 8px 0 10px; font-size: 14px; float: none; margin: 0; }

    /* ---- email preference switches: big tappable rows ---- */
    body .pf-pref { padding: 14px 0; gap: 14px; }
    body .pf-pref-text small { font-size: 13px; line-height: 1.45; }

    /* ---- pagination: two big buttons ---- */
    body .woocommerce-pagination.woocommerce-Pagination { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    body .woocommerce-pagination.woocommerce-Pagination a { width: 100%; text-align: center; display: flex; align-items: center; justify-content: center; }

    /* ---- notices ---- */
    body .woocommerce-message, body .woocommerce-error, body .woocommerce-info { margin: 0 0 12px; border-radius: 12px; font-size: 14px; }

    /* ======== CMS pages: policies, size guide, contact (help.css loads after this file, so `html body` prefixes win) ======== */
    html body .hp-primary { padding: 0 16px !important; }
    html body .hp { grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 12px 0 28px; }
    html body .hp-body { max-width: 100%; }
    html body .hp-nav { margin: 0 -16px; padding: 0 16px; }
    html body .hp-nav ul { padding: 2px 0 6px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
    html body .hp-nav li { flex: none; scroll-snap-align: start; }
    html body .hp-nav a { padding: 10px 15px; font-size: 14px; }
    html body .hp-title { font-size: 26px; padding-bottom: 12px; margin-bottom: 14px; overflow-wrap: anywhere; }
    html body .hp-content { font-size: 16px; line-height: 1.65; overflow-wrap: anywhere; }
    html body .hp-content h2 { font-size: 20px; margin-top: 24px; }
    html body .hp-content h3 { font-size: 17px; }
    html body .hp-content ul, html body .hp-content ol { margin-left: 18px; }
    html body .hp-content li { margin-bottom: 8px; }
    /* tables scroll inside their own box, never the whole page */
    html body .hp-content table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; font-size: 13px; border-radius: 12px; }
    html body .hp-content table th, html body .hp-content table td { min-width: 54px; padding: 9px 6px; overflow-wrap: break-word; }
    html body .hp-content table th { font-size: 11px; line-height: 1.3; letter-spacing: 0; }
    html body .hp-content figure { margin-left: 0; margin-right: 0; }
    html body .hp-content a { padding: 2px 0; }

    /* contact */
    html body .ct-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    html body .ct-lead { font-size: 15.5px; }
    html body .ct-card { padding: 14px; min-height: 64px; border-radius: 14px; }
    html body .ct-card:active { background: #f3f4f6; }
    html body .ct-form { padding: 18px 16px; border-radius: 16px; box-shadow: none; }
    html body .ct-form .wpcf7 label { font-size: 13px; }
    html body .ct-form .wpcf7 input[type=text], html body .ct-form .wpcf7 input[type=email], html body .ct-form .wpcf7 input[type=tel], html body .ct-form .wpcf7 textarea { font-size: 16px; min-height: 50px; border-radius: 12px; padding: 12px 14px; }
    html body .ct-form .wpcf7 textarea { min-height: 140px; }
    html body .ct-form .wpcf7 input[type=submit] { min-height: 52px; border-radius: 12px; font-size: 14px; }
}
