/**
 * Tag page — mobile UI (≤900px). Shell + form list styling from create-mobile.css.
 */
@media (max-width: 900px) {
    body.tag-page-mobile .mb40 {
        display: none !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden;
    }

    body.tag-page-mobile .second-bar {
        display: none !important;
    }

    /*
     * iOS settings-list form (edit sheet + compose).
     * !important overrides legacy tag.php + header mobile table styles.
     */
    body.tag-page-mobile .create-mobile-form-fields .labRow,
    body.tag-page-mobile .create-mobile-form-fields tr.all,
    body.tag-page-mobile .create-mobile-form-fields .set-all-row {
        display: block !important;
        border: none !important;
        margin: 0 !important;
        background: #fff !important;
        border-radius: 10px;
        overflow: hidden;
        box-shadow: none !important;
    }

    body.tag-page-mobile .create-mobile-form-fields .labRow > td[data-mobile-label],
    body.tag-page-mobile .create-mobile-form-fields tr.all > td[data-mobile-label],
    body.tag-page-mobile .create-mobile-form-fields .set-all-row > td[data-mobile-label] {
        display: flex !important;
        align-items: center;
        gap: 12px;
        min-height: 44px;
        margin: 0 !important;
        padding: 10px 16px !important;
        border: none !important;
        border-top: none !important;
        border-bottom: none !important;
        position: static !important;
        box-sizing: border-box;
        width: 100% !important;
        text-align: left !important;
    }

    body.tag-page-mobile .create-mobile-form-fields .labRow > td[data-mobile-label] ~ td[data-mobile-label],
    body.tag-page-mobile .create-mobile-form-fields tr.all > td[data-mobile-label] ~ td[data-mobile-label],
    body.tag-page-mobile .create-mobile-form-fields .set-all-row > td[data-mobile-label] ~ td[data-mobile-label] {
        border-top: 0.55px solid rgba(60, 60, 67, 0.18) !important;
    }

    body.tag-page-mobile .create-mobile-form-fields .labRow td::before,
    body.tag-page-mobile .create-mobile-form-fields tr.all td::before,
    body.tag-page-mobile .create-mobile-form-fields .set-all-row td::before {
        content: attr(data-mobile-label);
        flex: 0 1 42%;
        max-width: 42%;
        font-size: 17px;
        font-weight: 400;
        color: #000;
        margin: 0;
        letter-spacing: -0.02em;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    body.tag-page-mobile .create-mobile-form-fields .labRow > td[data-mobile-label]:has(textarea) {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px;
        min-height: 0;
        padding-top: 12px !important;
        padding-bottom: 12px !important;
    }

    body.tag-page-mobile .create-mobile-form-fields .labRow > td[data-mobile-label]:has(textarea)::before {
        flex: none;
        max-width: none;
        width: 100%;
    }

    body.tag-page-mobile .create-mobile-form-fields .labRow input,
    body.tag-page-mobile .create-mobile-form-fields .labRow select,
    body.tag-page-mobile .create-mobile-form-fields .labRow textarea,
    body.tag-page-mobile .create-mobile-form-fields tr.all input,
    body.tag-page-mobile .create-mobile-form-fields tr.all select,
    body.tag-page-mobile .create-mobile-form-fields .set-all-row input,
    body.tag-page-mobile .create-mobile-form-fields .set-all-row select {
        flex: 1 1 auto;
        min-width: 0;
        width: auto !important;
        height: auto !important;
        border: none !important;
        border-radius: 0;
        padding: 0 !important;
        margin: 0 !important;
        font-size: 17px !important;
        line-height: 1.35;
        box-sizing: border-box;
        background: transparent !important;
        box-shadow: none;
        color: #3c3c43;
        letter-spacing: -0.02em;
        -webkit-appearance: none;
        appearance: none;
    }

    body.tag-page-mobile .create-mobile-form-fields .labRow > td[data-mobile-label]:not(:has(textarea)):not(.labColorCell) input,
    body.tag-page-mobile .create-mobile-form-fields .labRow > td[data-mobile-label]:not(:has(textarea)):not(.labColorCell) select,
    body.tag-page-mobile .create-mobile-form-fields tr.all > td[data-mobile-label] input,
    body.tag-page-mobile .create-mobile-form-fields tr.all > td[data-mobile-label] select,
    body.tag-page-mobile .create-mobile-form-fields .set-all-row > td[data-mobile-label] input,
    body.tag-page-mobile .create-mobile-form-fields .set-all-row > td[data-mobile-label] select {
        text-align: right;
    }

    body.tag-page-mobile .create-mobile-form-fields .labRow select,
    body.tag-page-mobile .create-mobile-form-fields tr.all select,
    body.tag-page-mobile .create-mobile-form-fields .set-all-row select {
        padding-right: 18px !important;
        background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='13' viewBox='0 0 8 13'%3E%3Cpath fill='%23c7c7cc' d='M1.5 1.5 6.5 6.5 1.5 11.5'/%3E%3C/svg%3E") no-repeat right center !important;
        background-size: 8px 13px !important;
    }

    body.tag-page-mobile .create-mobile-form-fields .labRow textarea,
    body.tag-page-mobile .create-mobile-form-fields .labRow .labText {
        flex: 0 0 auto;
        width: 100% !important;
        min-height: 72px !important;
        max-height: 120px;
        height: auto !important;
        resize: none;
        overflow-y: auto;
        text-align: left !important;
        color: #000 !important;
        line-height: 1.4;
    }

    body.tag-page-mobile .create-mobile-form-fields tr.all > td:not(:has([data-change])),
    body.tag-page-mobile .create-mobile-form-fields .set-all-row > td:not(:has([data-change])) {
        display: none !important;
    }

    /* Hide desktop-only lab row cells in mobile form */
    .create-mobile-form-fields .labRow > td:first-child,
    .create-mobile-form-fields .labRow > td.price,
    .create-mobile-form-fields .labRow > td.adv-cell,
    .create-mobile-form-fields .labRow > td:not([data-mobile-label]) {
        display: none !important;
    }

    .create-mobile-form-fields .labRow label.desktop-hide {
        display: none !important;
    }

    /* mm suffix on measurement fields — value + unit flush right */
    .create-mobile-form-fields .labRow > td[data-mobile-label].tag-mobile-mm-cell,
    .create-mobile-form-fields tr.all > td[data-mobile-label].tag-mobile-mm-cell,
    .create-mobile-form-fields .set-all-row > td[data-mobile-label].tag-mobile-mm-cell {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto auto;
        align-items: center;
        gap: 4px 4px;
    }

    .create-mobile-form-fields .labRow > td[data-mobile-label].tag-mobile-mm-cell::before,
    .create-mobile-form-fields tr.all > td[data-mobile-label].tag-mobile-mm-cell::before,
    .create-mobile-form-fields .set-all-row > td[data-mobile-label].tag-mobile-mm-cell::before {
        grid-column: 1;
        max-width: none;
    }

    .create-mobile-form-fields .labRow > td[data-mobile-label].tag-mobile-mm-cell::after,
    .create-mobile-form-fields tr.all > td[data-mobile-label].tag-mobile-mm-cell::after,
    .create-mobile-form-fields .set-all-row > td[data-mobile-label].tag-mobile-mm-cell::after {
        content: 'mm';
        grid-column: 3;
        flex: none;
        font-size: 17px;
        color: #3c3c43;
        letter-spacing: -0.02em;
    }

    .create-mobile-form-fields .labRow > td[data-mobile-label].tag-mobile-mm-cell input,
    .create-mobile-form-fields tr.all > td[data-mobile-label].tag-mobile-mm-cell input,
    .create-mobile-form-fields .set-all-row > td[data-mobile-label].tag-mobile-mm-cell input {
        grid-column: 2;
        flex: none !important;
        width: auto !important;
        max-width: none;
        min-width: 3ch;
        margin: 0 !important;
        text-align: right;
    }

    /* Thickness read-only row */
    .create-mobile-form-fields .labRow > td.tag-mobile-thickness-row {
        cursor: default;
    }

    .create-mobile-form-fields .labRow > td.tag-mobile-thickness-row .tag-mobile-readonly-val {
        flex: 1 1 auto;
        text-align: right;
        font-size: 17px;
        color: #3c3c43;
        letter-spacing: -0.02em;
    }

    /* Colour row — summary + chevron, picker collapsed until tap */
    .create-mobile-form-fields .labRow > td.labColorCell {
        cursor: pointer;
        flex-wrap: wrap;
    }

    .create-mobile-form-fields .labRow > td.labColorCell .tag-mobile-color-native {
        display: none !important;
    }

    .create-mobile-form-fields .labRow > td.labColorCell .tag-mobile-color-summary {
        flex: 1 1 auto;
        text-align: right;
        font-size: 17px;
        color: #3c3c43;
        letter-spacing: -0.02em;
        padding-right: 18px;
        background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='13' viewBox='0 0 8 13'%3E%3Cpath fill='%23c7c7cc' d='M1.5 1.5 6.5 6.5 1.5 11.5'/%3E%3C/svg%3E") no-repeat right center;
        background-size: 8px 13px;
    }

    .create-mobile-form-fields .labRow > td.labColorCell .dd-color-options {
        display: none !important;
        position: static !important;
        flex: 1 1 100%;
        width: 100% !important;
        min-width: 0 !important;
        margin: 8px 0 0 !important;
        margin-left: 0 !important;
        padding: 12px;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        background: #fff;
        box-shadow: none;
        max-height: 240px;
        overflow: auto;
        z-index: 2;
        cursor: default;
        text-align: left;
    }

    .create-mobile-form-fields .labRow > td.labColorCell .dd-color-options.is-open {
        display: block !important;
    }

    .create-mobile-form-fields .labRow > td.labColorCell .dd-color-options h3,
    .create-mobile-form-fields .labRow > td.labColorCell .dd-color-options h4 {
        font-size: 14px;
        margin: 0 0 8px;
    }

    body.tag-page-mobile .create-mobile-form-fields .basic-material .color li {
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }

    body.tag-page-mobile .create-mobile-form-fields .basic-material .color li .tooltiptext {
        display: none !important;
    }

    body.tag-page-mobile .create-mobile-form-fields .basic-material .color li .color-square {
        pointer-events: none;
    }

    body.tag-page-mobile #createMobileSheetPreview.create-mobile-sheet__preview,
    body.tag-page-mobile #createMobileComposePreview.create-mobile-compose-preview {
        padding: 0 16px 12px;
    }

    body.tag-page-mobile #createMobileSheetPreview .create-row-preview,
    body.tag-page-mobile #createMobileSheetPreview .create-preview-item,
    body.tag-page-mobile #createMobileComposePreview .create-row-preview,
    body.tag-page-mobile #createMobileComposePreview .create-preview-item {
        margin-top: 0;
        margin-bottom: 0;
    }

    /* Card + sheet preview */
    .create-mobile-card__thumb .create-row-preview,
    .create-mobile-sheet__preview .create-row-preview,
    .create-mobile-compose-preview .create-row-preview {
        display: block;
        margin: 0 auto;
        overflow: visible;
    }

    .create-mobile-card__thumb .create-preview-face,
    .create-mobile-sheet__preview .create-preview-face,
    .create-mobile-compose-preview .create-preview-face {
        display: flex;
        align-items: center;
        justify-content: center;
        border: 1px solid #0f172a;
        box-sizing: border-box;
        overflow: hidden;
        margin: 0 auto;
        position: relative;
    }

    .create-mobile-card__thumb .create-preview-text,
    .create-mobile-sheet__preview .create-preview-text,
    .create-mobile-compose-preview .create-preview-text {
        flex: 1;
        text-align: center;
        line-height: inherit;
        word-break: break-word;
        color: inherit;
        font-family: Arial, Helvetica, sans-serif;
        min-height: 0;
        overflow: hidden;
    }

    .create-mobile-card__thumb .create-preview-face--hole-layout,
    .create-mobile-sheet__preview .create-preview-face--hole-layout,
    .create-mobile-compose-preview .create-preview-face--hole-layout {
        display: block;
        position: relative;
    }

    .create-mobile-card__thumb .create-preview-face--hole-layout .create-preview-hole-el,
    .create-mobile-sheet__preview .create-preview-face--hole-layout .create-preview-hole-el,
    .create-mobile-compose-preview .create-preview-face--hole-layout .create-preview-hole-el {
        z-index: 2;
        pointer-events: none;
    }

    .create-mobile-card__thumb .create-preview-text--absolute-fill,
    .create-mobile-sheet__preview .create-preview-text--absolute-fill,
    .create-mobile-compose-preview .create-preview-text--absolute-fill {
        position: absolute;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        box-sizing: border-box;
    }

    .create-mobile-card__thumb .tag-mobile-preview,
    .create-mobile-sheet__preview .tag-mobile-preview,
    .create-mobile-compose-preview .tag-mobile-preview {
        border-radius: 4px;
        text-align: center;
        line-height: 1.2;
        word-break: break-word;
        box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
    }

    .create-mobile-card__thumb .tag-mobile-preview--advanced .tag-label-svg-fit,
    .create-mobile-sheet__preview .tag-mobile-preview--advanced .tag-label-svg-fit {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        line-height: 0;
        overflow: hidden;
    }

    .create-mobile-card__thumb .tag-mobile-preview--advanced .tag-label-svg-fit svg,
    .create-mobile-sheet__preview .tag-mobile-preview--advanced .tag-label-svg-fit svg {
        width: 100% !important;
        height: 100% !important;
        max-width: 100%;
        max-height: 100%;
        display: block;
    }

    .tag-mobile-advanced-notice {
        margin: 0;
        padding: 16px;
        border-radius: 10px;
        background: #fffbeb;
        border: 1px solid #fcd34d;
        color: #78350f;
    }

    .tag-mobile-advanced-notice__title {
        margin: 0 0 8px;
        font-size: 17px;
        font-weight: 600;
        color: #92400e;
    }

    .tag-mobile-advanced-notice__text,
    .tag-mobile-advanced-notice__hint {
        margin: 0;
        font-size: 15px;
        line-height: 1.45;
    }

    .tag-mobile-advanced-notice__hint {
        margin-top: 10px;
        color: #a16207;
    }

    .create-mobile-sheet--advanced-readonly .create-mobile-sheet__body {
        padding: 0 16px 16px;
    }

    body.tag-page-mobile .create-mobile-form-fields .labRow.active-label-row > td,
    body.tag-page-mobile .create-mobile-form-fields .active-label-row > td {
        background: transparent !important;
    }

    body.tag-page-mobile .tag-product-details {
        display: none;
        padding: 0 16px 24px;
        background: #fff;
    }

    body.tag-page-mobile .tag-product-details.is-visible {
        display: block;
    }
}

/* Finish later modal — above mobile app (footer 10040), edit sheet (10060), site chrome */
body.tag-page-mobile .modal-save {
    position: fixed !important;
    inset: 0 !important;
    z-index: 10000100 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: none !important;
    height: 100% !important;
    align-items: center;
    justify-content: center;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    background: rgba(15, 23, 42, 0.45) !important;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: none !important;
    text-align: left;
}

body.tag-page-mobile .modal-save.is-open {
    display: flex !important;
}

body.tag-page-mobile .modal-save .cont {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    margin: auto !important;
    width: 100%;
    max-width: 480px;
    transform: none !important;
    border-radius: 14px;
    padding: 24px 20px;
    max-height: min(calc(100vh - 32px), 640px);
    overflow-y: auto;
    box-sizing: border-box;
    text-align: left;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
}

body.tag-page-mobile .modal-save .save-email {
    width: 100%;
    box-sizing: border-box;
    font-size: 16px;
    padding: 10px 12px;
    margin: 8px 0;
}

body.tag-page-mobile .modal-save .btn {
    font-size: 16px;
    width: 100%;
    float: none !important;
    display: inline-block;
    box-sizing: border-box;
}

body.tag-page-mobile .modal-save .row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

body.tag-page-mobile .modal-save .row .col-6 {
    width: 100%;
    max-width: none;
    text-align: center !important;
    float: none !important;
}

body.tag-finish-later-open {
    overflow: hidden;
}
