/**
 * Matrimony Profile — v3.3.0
 * Design: Warm & Refined — Earthy tones, clean typography, modern cards
 * Includes: Share bar, Modals, Design picker, PDF preview
 *
 * v3.3.0 — Cross-browser + mobile pass
 *   - Tables collapse into cards on phones (no horizontal scroll)
 *   - iOS: no input zoom (16px inputs), safe-area insets, dvh-based modals
 *   - Modals become bottom sheets on phones; PDF preview goes full screen
 *   - :has() replaced by a JS-driven class (Firefox < 121, Safari < 15.4)
 *   - -webkit- prefixes for Safari (backdrop-filter, user-select, filter)
 *   - Firefox range-track styling, touch-size targets for coarse pointers
 *   - Hover effects only on devices that can hover (no "sticky hover")
 *   - Flex-gap fallback for Safari < 14.1
 *   - Styles for the Search view (previously unstyled)
 */

:root {
    --mp-font: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial,
               'Noto Sans', 'Noto Sans Devanagari', 'Nirmala UI', Mangal, sans-serif;
    --mp-font-display: Georgia, 'Times New Roman', 'Noto Serif Devanagari', serif;
    --mp-bg: #faf9f7;
    --mp-surface: #ffffff;
    --mp-border: #e8e4df;
    --mp-border-light: #f0ece7;
    --mp-text: #2c2520;
    --mp-text-secondary: #7a7067;
    --mp-text-muted: #a89f95;
    --mp-accent: #b45309;
    --mp-accent-light: #fef3c7;
    --mp-accent-hover: #92400e;
    --mp-teal: #0d9488;
    --mp-teal-light: #ccfbf1;
    --mp-red: #dc2626;
    --mp-hero-from: #1c1917;
    --mp-hero-to: #44403c;
    --mp-radius: 10px;
    --mp-radius-sm: 6px;
    --mp-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --mp-shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --mp-bar-h: 68px;
    --mp-safe-bottom: 0px;
}
@supports (padding: env(safe-area-inset-bottom)) {
    :root { --mp-safe-bottom: env(safe-area-inset-bottom); }
}


/* ═══ BASE (scoped — never touches the theme) ═══ */

.mp-page, .mp-page *, .mp-page *::before, .mp-page *::after,
.matrimony-container, .matrimony-container *, .matrimony-container *::before, .matrimony-container *::after,
.mp-share-modal, .mp-share-modal *, .mp-share-modal *::before, .mp-share-modal *::after {
    box-sizing: border-box;
}
.mp-page, .matrimony-container, .mp-share-modal {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
.mp-page img, .matrimony-container img, .mp-share-modal img { max-width: 100%; }

/* Taps: no 300ms delay, no grey flash on iOS/Android */
.mp-page button, .matrimony-container button, .mp-share-modal button,
.mp-btn, .matrimony-btn, .mp-share-btn, .mp-pdf-toggle, .mp-inline-edit-btn,
.mp-photo-item, .mp-design-card, .mp-share-house-item, .mp-section__header--toggle {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Visible keyboard focus everywhere (separate rules — older browsers drop unknown selectors) */
.mp-btn:focus-visible, .matrimony-btn:focus-visible, .mp-share-modal__close:focus-visible,
.mp-section__header--toggle:focus-visible, .mp-inline-edit-btn:focus-visible {
    outline: 2px solid var(--mp-teal);
    outline-offset: 2px;
}


/* ═══ PAGE ═══ */

.mp-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px 60px;
    font-family: var(--mp-font);
    color: var(--mp-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}


/* ═══ HERO ═══ */

.mp-hero {
    background: var(--mp-hero-from);
    background: linear-gradient(135deg, var(--mp-hero-from), var(--mp-hero-to));
    border-radius: var(--mp-radius);
    padding: 48px 40px;
    margin-bottom: 32px;
    position: relative;
    overflow: hidden;
}
.mp-hero::before {
    content: '';
    position: absolute;
    top: -50%; right: -20%;
    width: 400px; height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(180,83,9,0.15) 0%, transparent 70%);
    pointer-events: none;
}
.mp-hero::after {
    content: '';
    position: absolute;
    bottom: -30%; left: 10%;
    width: 300px; height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(13,148,136,0.1) 0%, transparent 70%);
    pointer-events: none;
}
.mp-hero__inner { position: relative; z-index: 1; }
.mp-hero__badge {
    display: inline-block;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.8);
    font-size: 11px; font-weight: 600;
    letter-spacing: 1.5px; text-transform: uppercase;
    padding: 5px 14px; border-radius: 100px;
    margin-bottom: 16px;
}
.mp-hero__title {
    font-family: var(--mp-font-display);
    font-size: 30px; font-weight: 700;
    color: #fff; margin: 0 0 8px; line-height: 1.2;
    overflow-wrap: break-word; word-wrap: break-word;
}
.mp-hero__subtitle {
    font-size: 15px; color: rgba(255,255,255,0.6);
    margin: 0; font-weight: 400;
}


/* ═══ SECTIONS ═══ */

.mp-section {
    background: var(--mp-surface);
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius);
    margin-bottom: 24px;
    box-shadow: var(--mp-shadow);
}
.mp-section__header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--mp-border-light);
    display: -webkit-box; display: -ms-flexbox; display: flex;
    -webkit-box-align: center; -ms-flex-align: center; align-items: center;
    -ms-flex-wrap: wrap; flex-wrap: wrap;
    gap: 8px;
}
.mp-section__header--toggle {
    cursor: pointer;
    -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
    transition: background 0.15s;
}
.mp-section__title {
    font-size: 16px; font-weight: 700;
    color: var(--mp-text); margin: 0;
    display: flex; align-items: center; gap: 8px;
}
.mp-section__icon { font-size: 8px; color: var(--mp-accent); }
.mp-section__subtitle {
    font-size: 13px; color: var(--mp-text-muted); margin-left: auto;
}
.mp-toggle-icon {
    margin-left: auto; font-size: 14px;
    color: var(--mp-text-muted); transition: transform 0.2s;
}
.mp-section__header--open .mp-toggle-icon { -webkit-transform: rotate(180deg); transform: rotate(180deg); }
.mp-section__body { padding: 0; }


/* ═══ TABLE (lists) ═══ */

.mp-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.mp-table { width: 100%; border-collapse: collapse; }
.mp-table th {
    background: var(--mp-bg);
    font-size: 11px; font-weight: 700;
    color: var(--mp-text-muted);
    text-transform: uppercase; letter-spacing: 0.8px;
    padding: 10px 20px; text-align: left;
    border-bottom: 1px solid var(--mp-border-light);
}
.mp-table th:last-child { text-align: right; }
.mp-table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--mp-border-light);
    vertical-align: middle; font-size: 14px;
}
.mp-table tr:last-child td { border-bottom: none; }
.mp-avatar {
    width: 40px; height: 40px;
    border-radius: 50%; object-fit: cover;
    border: 2px solid var(--mp-border-light);
    display: block;
}
.mp-name { font-weight: 600; color: var(--mp-text); font-size: 14px; }
.mp-meta { font-size: 12px; color: var(--mp-text-muted); margin-top: 2px; }
.mp-actions { text-align: right; white-space: nowrap; }
.mp-actions .mp-btn + .mp-btn { margin-left: 4px; }
.mp-muted { color: var(--mp-text-muted); }


/* ═══ PROFILE CARDS ═══ */

.mp-profiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
    gap: 20px; padding: 24px;
}
.mp-profile-card {
    background: var(--mp-surface);
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius);
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
}
.mp-profile-card__top {
    display: flex; align-items: center;
    gap: 14px; padding: 18px 20px;
    border-bottom: 1px solid var(--mp-border-light);
}
.mp-profile-card__avatar {
    width: 52px; height: 52px;
    border-radius: 50%; object-fit: cover;
    border: 2px solid var(--mp-border-light);
    flex-shrink: 0;
}
.mp-profile-card__info { flex: 1; min-width: 0; }
.mp-profile-card__name {
    font-weight: 700; font-size: 15px;
    color: var(--mp-text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mp-profile-card__detail {
    font-size: 12px; color: var(--mp-text-muted); margin-top: 2px;
}
.mp-profile-card__status {
    display: inline-block;
    font-size: 11px; font-weight: 600;
    padding: 3px 10px; border-radius: 100px;
    letter-spacing: 0.3px; flex-shrink: 0;
}
.mp-profile-card__status--active {
    background: var(--mp-teal-light); color: var(--mp-teal);
}
.mp-profile-card__status--inactive {
    background: #f5f5f5; color: #999;
}
.mp-profile-card__body {
    padding: 16px 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
}
.mp-profile-card__field { font-size: 12px; min-width: 0; }
.mp-profile-card__field-label { color: var(--mp-text-muted); margin-bottom: 2px; }
.mp-profile-card__field-value { color: var(--mp-text); font-weight: 500; overflow-wrap: break-word; }
.mp-profile-card__footer {
    padding: 12px 20px;
    border-top: 1px solid var(--mp-border-light);
    display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
}


/* ═══ BUTTONS ═══ */

.mp-btn {
    display: -webkit-inline-box; display: -ms-inline-flexbox; display: inline-flex;
    -webkit-box-align: center; -ms-flex-align: center; align-items: center;
    -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center;
    gap: 6px; padding: 8px 18px; border: none;
    border-radius: var(--mp-radius-sm);
    font-family: var(--mp-font); font-size: 13px; font-weight: 600;
    cursor: pointer; transition: background-color 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.15s;
    text-decoration: none; line-height: 1.4;
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    vertical-align: middle;
}
.mp-btn:disabled, .mp-btn[disabled] { opacity: 0.6; cursor: not-allowed; }
.mp-btn--primary { background: var(--mp-accent); color: #fff; }
.mp-btn--secondary {
    background: var(--mp-bg); color: var(--mp-text);
    border: 1px solid var(--mp-border);
}
.mp-btn--ghost {
    background: transparent; color: var(--mp-text-secondary);
    border: 1px solid var(--mp-border);
}
.mp-btn--teal { background: var(--mp-teal); color: #fff; }
.mp-btn--sm { padding: 5px 12px; font-size: 12px; }
.mp-btn--xs {
    font-size: 11px; padding: 3px 8px;
    border-radius: 4px; line-height: 1.3;
}
.mp-btn--danger { color: var(--mp-red, #dc3545); }


/* ═══ FILTER FORM ═══ */

.mp-filter-form { padding: 20px 24px; }
.mp-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr));
    gap: 16px; align-items: end;
}
.mp-field { display: flex; flex-direction: column; min-width: 0; }
.mp-field--actions {
    display: flex; flex-direction: row; flex-wrap: wrap;
    gap: 8px; align-items: flex-end; padding-bottom: 1px;
}
.mp-label {
    font-size: 12px; font-weight: 600;
    color: var(--mp-text-secondary);
    margin-bottom: 5px; letter-spacing: 0.2px;
}

/* Shared input look (filters + forms) */
.mp-input,
.matrimony-input {
    display: block;
    width: 100%; max-width: 100%; min-width: 0;
    min-height: 38px;
    padding: 9px 12px;
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius-sm);
    font-size: 13px; font-family: var(--mp-font);
    line-height: 1.4;
    color: var(--mp-text); background-color: var(--mp-surface);
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
    margin: 0;
}
/* Strip iOS inner shadow / rounded corners on text-like inputs only */
input.mp-input, input.matrimony-input,
textarea.mp-input, textarea.matrimony-input {
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
}
/* Keep native checkbox/radio/file/range */
input[type="checkbox"].matrimony-input, input[type="radio"].matrimony-input,
input[type="range"].matrimony-input, input[type="file"].matrimony-input {
    -webkit-appearance: auto; appearance: auto; width: auto; min-height: 0;
}
.mp-input:focus, .matrimony-input:focus {
    outline: none; border-color: var(--mp-accent);
    box-shadow: 0 0 0 3px rgba(180,83,9,0.12);
}
.mp-input::-webkit-input-placeholder, .matrimony-input::-webkit-input-placeholder { color: var(--mp-text-muted); }
.mp-input::-moz-placeholder, .matrimony-input::-moz-placeholder { color: var(--mp-text-muted); opacity: 1; }
.mp-input::placeholder, .matrimony-input::placeholder { color: var(--mp-text-muted); opacity: 1; }
select.mp-input, select.matrimony-input {
    cursor: pointer;
    -webkit-appearance: auto; -moz-appearance: auto; appearance: auto;
    padding-right: 8px;
}
textarea.mp-input, textarea.matrimony-input { resize: vertical; min-height: 72px; }

/* Date / time inputs: consistent height in Safari (iOS + macOS) */
.matrimony-input::-webkit-date-and-time-value { min-width: 85px; height: 1.4em; margin: 0; text-align: left; }
.matrimony-input::-webkit-datetime-edit { display: block; padding: 0; }
.matrimony-input::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.6; }

/* Firefox: number inputs sometimes ignore width inside flex */
input[type="number"].matrimony-input, input[type="number"].mp-input { -moz-appearance: textfield; }

/* Side-by-side range inputs (Age From / To etc.) */
.mp-range {
    display: flex; gap: 10px; width: 100%;
}
.mp-range > * { -webkit-box-flex: 1; -ms-flex: 1 1 0%; flex: 1 1 0%; min-width: 0; }


/* ═══ LOADING ═══ */

.mp-loading, .matrimony-loading {
    display: flex; align-items: center; justify-content: center;
    gap: 10px; padding: 48px 20px;
    color: var(--mp-text-muted); font-size: 14px;
    font-family: var(--mp-font);
}
.mp-loading__spinner {
    width: 18px; height: 18px;
    border: 2px solid var(--mp-border);
    border-top-color: var(--mp-accent);
    border-radius: 50%;
    -webkit-animation: mp-spin 0.7s linear infinite;
    animation: mp-spin 0.7s linear infinite;
    flex-shrink: 0;
}
@-webkit-keyframes mp-spin { to { -webkit-transform: rotate(360deg); transform: rotate(360deg); } }
@keyframes mp-spin { to { -webkit-transform: rotate(360deg); transform: rotate(360deg); } }


/* ═══ EMPTY & ALERTS ═══ */

.mp-empty, .matrimony-no-results {
    text-align: center; padding: 48px 20px;
    color: var(--mp-text-muted); font-size: 14px;
}
.mp-empty__icon { font-size: 32px; margin-bottom: 12px; opacity: 0.3; }

.matrimony-alert {
    padding: 16px 20px; border-radius: var(--mp-radius-sm);
    margin: 20px; font-size: 14px;
    font-family: var(--mp-font);
}
.matrimony-alert h3 { margin: 0 0 6px; }
.matrimony-alert-success { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.matrimony-alert-error { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.matrimony-alert-warning { background: var(--mp-accent-light); border: 1px solid #fde68a; color: var(--mp-accent-hover); }


/* ═══ LOGIN REQUIRED ═══ */

.matrimony-login-required { max-width: 480px; margin: 60px auto; padding: 0 16px; text-align: center; font-family: var(--mp-font); }
.matrimony-login-required h3 { margin: 0 0 8px; font-size: 22px; color: var(--mp-text); }
.matrimony-login-required p { margin: 0; color: var(--mp-text-secondary); }

.matrimony-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 22px; border: none; border-radius: var(--mp-radius-sm);
    font-family: var(--mp-font); font-size: 14px; font-weight: 600; cursor: pointer;
    text-decoration: none; transition: background-color 0.15s, border-color 0.15s;
    -webkit-appearance: none; appearance: none; line-height: 1.4;
}
.matrimony-btn:disabled, .matrimony-btn[disabled] { opacity: 0.6; cursor: not-allowed; }
.matrimony-btn-primary { background: var(--mp-accent); color: #fff; }
.matrimony-btn-secondary { background: var(--mp-bg); color: var(--mp-text); border: 1px solid var(--mp-border); }
.matrimony-btn .dashicons { font-size: 18px; width: 18px; height: 18px; line-height: 1; }


/* ═══ FORM PAGES (create/edit) ═══ */

.matrimony-container {
    max-width: 1100px; margin: 0 auto; padding: 4px 20px 20px;
    font-family: var(--mp-font);
    color: var(--mp-text);
}
.matrimony-header {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 12px;
    margin-bottom: 24px; padding-bottom: 16px;
    border-bottom: 1px solid var(--mp-border);
}
.matrimony-header h2 { margin: 0; font-size: 24px; color: var(--mp-text); }
.matrimony-profile-form {
    background: var(--mp-surface);
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius);
    padding: 28px;
    /* room for the fixed save bar */
    padding-bottom: 96px;
    padding-bottom: calc(var(--mp-bar-h) + 28px + var(--mp-safe-bottom));
}
.matrimony-form-section {
    margin-bottom: 28px; padding-bottom: 28px;
    border-bottom: 1px solid var(--mp-border-light);
}
.matrimony-form-section:last-of-type { border-bottom: none; }
.matrimony-form-section h3 {
    margin: 0 0 18px; font-size: 17px;
    color: var(--mp-text); font-weight: 700;
}
.matrimony-profile-form .form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
    gap: 18px; margin-bottom: 14px;
}
.matrimony-profile-form .form-col { display: flex; flex-direction: column; min-width: 0; }
.mp-col-full { grid-column: 1 / -1; }
.matrimony-profile-form label {
    font-size: 13px; font-weight: 600;
    color: var(--mp-text-secondary); margin-bottom: 5px;
}
.matrimony-profile-form label .required { color: var(--mp-red); }

/* Fixed save bar */
.matrimony-form-actions {
    display: flex; gap: 12px;
    padding: 14px 28px;
    padding-bottom: calc(14px + var(--mp-safe-bottom));
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--mp-surface);
    z-index: 9999;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.1);
    border-top: 1px solid var(--mp-border);
    justify-content: center;
    -webkit-transform: translateZ(0); transform: translateZ(0); /* iOS: avoid repaint jitter while scrolling */
    transition: -webkit-transform 0.2s ease; transition: transform 0.2s ease;
}
/* Hidden while the on-screen keyboard is open (class set by JS) */
body.mp-keyboard-open .matrimony-form-actions {
    -webkit-transform: translateY(110%); transform: translateY(110%);
}
.matrimony-message { margin: 16px 0; }


/* ═══ SEARCH VIEW ═══ */

.matrimony-filters {
    background: var(--mp-surface);
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius);
    padding: 20px 24px;
    margin-bottom: 24px;
}
.matrimony-filters h3 { margin: 0 0 16px; font-size: 16px; color: var(--mp-text); }
.matrimony-filter-form .filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
    gap: 16px; margin-bottom: 16px; align-items: end;
}
.matrimony-filter-form .filter-row:last-child { margin-bottom: 0; }
.matrimony-filter-form .filter-col { display: flex; flex-direction: column; min-width: 0; }
.matrimony-filter-form label {
    font-size: 12px; font-weight: 600; color: var(--mp-text-secondary); margin-bottom: 5px;
}
.matrimony-members-list {
    background: var(--mp-surface);
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius);
}


/* ═══ PAGINATION ═══ */

.mp-pagination {
    display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 24px;
}
.mp-pagination button {
    padding: 7px 14px; border: 1px solid var(--mp-border);
    background: var(--mp-surface); color: var(--mp-text-secondary);
    border-radius: var(--mp-radius-sm); font-size: 13px;
    cursor: pointer; transition: background-color 0.15s;
    min-width: 36px;
}
.mp-pagination button.active { background: var(--mp-accent); color: white; border-color: var(--mp-accent); }


/* ═══ PROFILE VIEW — header card ═══ */

.mp-view-topbar {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px;
}
.mp-view-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.mp-view-actions .mp-btn { margin: 0; }
.mp-view-body { padding: 20px; }

.mp-view-head {
    display: flex; align-items: center; flex-wrap: wrap;
    gap: 24px; padding: 20px;
    background: #fff;
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius);
    margin-bottom: 24px;
    box-shadow: var(--mp-shadow);
}
.mp-view-head__photo { flex-shrink: 0; position: relative; }
.mp-view-head__photo-btn {
    display: block; position: relative;
    padding: 0; margin: 0; border: 0; background: none;
    cursor: zoom-in; border-radius: 50%;
    transition: transform 0.2s;
}
.mp-view-head__img {
    display: block;
    width: 120px; height: 120px;
    object-fit: cover; border-radius: 50%;
    border: 3px solid var(--mp-border);
    box-shadow: var(--mp-shadow-md);
}
.mp-view-head__zoom {
    position: absolute; bottom: 0; right: 0;
    background: var(--mp-teal); color: #fff;
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.mp-view-head__placeholder {
    flex-shrink: 0; width: 120px; height: 120px; border-radius: 50%;
    background: var(--mp-border-light);
    display: flex; align-items: center; justify-content: center;
    font-size: 40px; color: var(--mp-text-muted);
    border: 3px solid var(--mp-border);
}
.mp-view-head__info { -webkit-box-flex: 1; -ms-flex: 1 1 200px; flex: 1 1 200px; min-width: 0; }
.mp-view-head__name {
    font-size: 24px; font-weight: 700; color: var(--mp-text);
    margin-bottom: 4px; line-height: 1.25;
    overflow-wrap: break-word; word-wrap: break-word;
}
.mp-view-head__sub { font-size: 14px; color: var(--mp-text-muted); margin-bottom: 12px; }
.mp-view-head__chips { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; font-weight: 600; }
.mp-chip {
    background: var(--mp-bg); padding: 5px 12px;
    border-radius: 100px; border: 1px solid var(--mp-border-light);
    color: var(--mp-text-secondary);
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Key/value detail table (profile view + imported data) */
.mp-inline-table td, .mp-inline-table th { overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; }
.mp-pdf-toggle { white-space: nowrap; -webkit-user-select: none; user-select: none; }


/* ═══ SHARE BAR ═══ */

.mp-share-bar {
    margin-top: 28px;
    padding: 20px 24px;
    background: #f5f0eb;
    background: linear-gradient(135deg, #faf9f7 0%, #f5f0eb 100%);
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.mp-share-bar__title {
    font-size: 15px; font-weight: 700;
    color: var(--mp-text); letter-spacing: 0.2px;
}
.mp-share-bar__actions {
    display: flex; gap: 10px; flex-wrap: wrap;
}
.mp-view-footer { margin-top: 16px; text-align: center; }

.mp-share-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px !important;
    font-size: 13px; font-weight: 600;
    border-radius: var(--mp-radius-sm);
    cursor: pointer; transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid transparent;
}
.mp-share-btn__icon { font-size: 15px; line-height: 1; }

.mp-share-btn--whatsapp {
    background-color: #25D366 !important;
    color: #fff !important;
    border-color: #1da851 !important;
}
.mp-share-btn--house {
    background-color: var(--mp-accent) !important;
    color: #fff !important;
    border-color: var(--mp-accent-hover) !important;
}


/* ═══ MODAL (shared base for all modals) ═══ */

.mp-share-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 10000;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
    padding-bottom: calc(16px + var(--mp-safe-bottom));
    font-family: var(--mp-font);
    color: var(--mp-text);
}
.mp-share-modal__overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}
.mp-share-modal__dialog {
    position: relative;
    background: var(--mp-surface);
    border-radius: var(--mp-radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    width: 100%; max-width: 520px;
    max-height: 85vh;
    max-height: 85dvh;
    display: flex; flex-direction: column;
    overflow: hidden;
    -webkit-animation: mp-modal-in 0.25s ease;
    animation: mp-modal-in 0.25s ease;
}
@-webkit-keyframes mp-modal-in {
    from { opacity: 0; -webkit-transform: scale(0.95) translateY(10px); transform: scale(0.95) translateY(10px); }
    to   { opacity: 1; -webkit-transform: none; transform: none; }
}
@keyframes mp-modal-in {
    from { opacity: 0; -webkit-transform: scale(0.95) translateY(10px); transform: scale(0.95) translateY(10px); }
    to   { opacity: 1; -webkit-transform: none; transform: none; }
}
@-webkit-keyframes mp-sheet-in {
    from { -webkit-transform: translateY(100%); transform: translateY(100%); }
    to   { -webkit-transform: none; transform: none; }
}
@keyframes mp-sheet-in {
    from { -webkit-transform: translateY(100%); transform: translateY(100%); }
    to   { -webkit-transform: none; transform: none; }
}
.mp-share-modal__header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--mp-border);
    background: #faf9f7;
    flex-shrink: 0;
}
.mp-share-modal__title {
    font-size: 16px; font-weight: 700;
    color: var(--mp-text); margin: 0;
    min-width: 0;
}
.mp-share-modal__close {
    background: none; border: none;
    font-size: 26px; color: var(--mp-text-muted);
    cursor: pointer; padding: 0; line-height: 1;
    width: 36px; height: 36px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    transition: color 0.15s, background-color 0.15s;
}
.mp-share-modal__body {
    padding: 20px 24px;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    -ms-scroll-chaining: none; overscroll-behavior: contain;
    -webkit-box-flex: 1; -ms-flex: 1 1 auto; flex: 1 1 auto;
    min-height: 0;
}
.mp-share-modal__footer {
    display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap;
    gap: 10px; padding: 16px 24px;
    border-top: 1px solid var(--mp-border);
    background: #faf9f7;
    flex-shrink: 0;
}

/* Enlarged photo */
.mp-enlarge__wrap {
    position: relative; z-index: 1;
    max-width: 90vw; max-height: 90vh; max-height: 90dvh;
    -webkit-animation: mp-modal-in 0.25s ease; animation: mp-modal-in 0.25s ease;
}
.mp-enlarge__img {
    display: block;
    max-width: 90vw; max-height: 90vh; max-height: 90dvh;
    border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    object-fit: contain; background: #000;
}
.mp-enlarge__close {
    position: absolute; top: -15px; right: -15px;
    background: #fff; color: #000; border: none;
    width: 36px; height: 36px; border-radius: 50%;
    font-size: 24px; line-height: 1; cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: flex; align-items: center; justify-content: center;
}


/* ═══ PHOTO GALLERY MODAL ═══ */

.mp-gallery-upload {
    position: relative;
    border: 2px dashed var(--mp-border);
    border-radius: var(--mp-radius);
    background: var(--mp-bg);
    transition: border-color 0.2s, background-color 0.2s;
}
.mp-gallery-upload__label {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; padding: 20px; cursor: pointer; text-align: center;
}
.mp-gallery-upload__icon { font-size: 28px; opacity: 0.7; }
.mp-gallery-upload__text { font-size: 13px; font-weight: 600; color: var(--mp-text); }
.mp-gallery-upload__hint { font-size: 11px; color: var(--mp-text-muted); }

.mp-gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}
.mp-gallery-card {
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius-sm);
    overflow: hidden;
    background: var(--mp-surface);
    transition: box-shadow 0.2s;
    min-width: 0;
}
.mp-gallery-card__img-wrap {
    position: relative;
    width: 100%; height: 140px;
    overflow: hidden; background: #f5f5f5;
}
.mp-gallery-card__img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.mp-gallery-card__actions {
    display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
    gap: 6px; padding: 8px 6px;
    border-top: 1px solid var(--mp-border);
    background: #faf9f7;
}
.mp-gallery-badge {
    position: absolute; top: 6px; left: 6px;
    font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
    padding: 2px 8px; border-radius: 10px;
}
.mp-gallery-badge--primary {
    background: var(--mp-accent); color: #fff;
}
.mp-upload-progress { text-align: center; padding: 12px; color: var(--mp-text-muted); font-size: 13px; }
.mp-upload-progress .mp-loading__spinner { display: inline-block; vertical-align: middle; margin-right: 8px; }


/* ═══ HOUSE PICKER ═══ */

.mp-share-houses {
    max-height: 240px; max-height: 40dvh;
    overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius-sm);
    background: #fff;
}
.mp-share-house-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; cursor: pointer;
    min-height: 48px;
    transition: background-color 0.15s;
    border-bottom: 1px solid var(--mp-border-light);
}
.mp-share-house-item:last-child { border-bottom: none; }
.mp-share-house-checkbox {
    width: 20px; height: 20px;
    accent-color: var(--mp-teal);
    cursor: pointer; flex-shrink: 0; margin: 0;
}
.mp-share-house-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mp-share-house-name { font-size: 14px; font-weight: 600; color: var(--mp-text); overflow-wrap: break-word; }
.mp-share-house-type { font-size: 11px; color: var(--mp-text-muted); text-transform: capitalize; }

.mp-share-message-wrap .mp-label {
    font-size: 13px; font-weight: 600;
    color: var(--mp-text-secondary);
    margin-bottom: 6px; display: block;
}
.mp-share-message-wrap .mp-input {
    width: 100%; resize: vertical; min-height: 48px;
}


/* ═══ DESIGN PICKER ═══ */

.mp-design-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.mp-design-card {
    position: relative; cursor: pointer; display: block;
    border: 2px solid var(--mp-border);
    border-radius: var(--mp-radius);
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    background: var(--mp-surface);
    padding-bottom: 10px;
    margin: 0;
}
.mp-design-radio {
    position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0;
    pointer-events: none;
}
/* Selected state is a CLASS set by JS — works in every browser.
   (Old version used :has(), which Firefox < 121 and Safari < 15.4 ignore.) */
.mp-design-card.mp-design-card--selected {
    border-color: var(--mp-teal);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.2), 0 4px 12px rgba(13, 148, 136, 0.15);
}
.mp-design-card.mp-design-card--selected::after {
    content: '\2713';
    position: absolute; top: 8px; right: 8px;
    width: 22px; height: 22px;
    background: var(--mp-teal); color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: bold; z-index: 2;
    line-height: 22px; text-align: center;
}
.mp-design-card.mp-design-card--focus {
    outline: 2px solid var(--mp-teal); outline-offset: 2px;
}
.mp-design-preview {
    height: 100px; overflow: hidden;
    position: relative;
    border-bottom: 1px solid var(--mp-border-light);
}
.mp-design-preview__header { padding: 8px 10px 6px; position: relative; }
.mp-design-preview__body { padding: 6px 10px; }
.mp-design-label {
    font-size: 13px; font-weight: 700;
    color: var(--mp-text); padding: 8px 12px 2px;
}
.mp-design-desc {
    font-size: 11px; color: var(--mp-text-muted);
    padding: 0 12px 4px;
}


/* ═══ PDF PREVIEW ═══ */

.mp-share-modal__dialog.mp-preview-dialog {
    max-width: 750px;
    height: 90vh;
    height: 90dvh;
    max-height: none;
    display: flex; flex-direction: column;
}
.mp-preview-body {
    -webkit-box-flex: 1; -ms-flex: 1 1 auto; flex: 1 1 auto;
    padding: 12px !important;
    overflow: hidden; display: flex;
    min-height: 0;
}
.mp-pdf-viewer {
    -webkit-box-flex: 1; -ms-flex: 1 1 auto; flex: 1 1 auto;
    display: flex;
    align-items: center; justify-content: center;
    background: #e5e5e5;
    border-radius: var(--mp-radius-sm);
    overflow: hidden;
    min-height: 0; min-width: 0;
}
/* pdf.js page-canvas mode (iOS, Android, browsers without a built-in PDF viewer) */
.mp-pdf-viewer.mp-pdf-viewer--pages {
    display: block;
    overflow-y: auto; overflow-x: hidden;
    -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
    padding: 8px;
}
.mp-pdf-page {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto 10px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.mp-pdf-fallback {
    text-align: center; padding: 24px 16px;
    color: var(--mp-text-secondary); font-size: 14px;
}
.mp-pdf-fallback__icon { font-size: 40px; margin-bottom: 8px; }
.mp-pdf-fallback p { margin: 0 0 14px; }
.mp-pdf-iframe {
    width: 100%; height: 100%;
    border: none;
    border-radius: var(--mp-radius-sm);
    display: block;
}
.mp-share-modal__footer.mp-preview-footer {
    justify-content: space-between;
}
.mp-preview-actions {
    display: flex; gap: 8px; flex-wrap: wrap;
}


/* ═══ INLINE EDITING ═══ */

.mp-inline-row {
    position: relative;
    transition: background-color 0.2s;
}
.mp-inline-empty .mp-inline-value {
    color: var(--mp-text-muted);
    font-style: italic;
}
.mp-inline-row[data-field] > td { padding-right: 46px !important; }
.mp-inline-edit-btn {
    opacity: 0;
    position: absolute;
    right: 10px;
    top: 50%;
    -webkit-transform: translateY(-50%); transform: translateY(-50%);
    cursor: pointer;
    font-size: 14px;
    color: var(--mp-teal);
    background: var(--mp-teal-light);
    border: 1px solid rgba(13, 148, 136, 0.2);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, background-color 0.15s;
    line-height: 1;
}
.mp-inline-edit-btn:focus { opacity: 1; }
.mp-inline-editing {
    background: #f0fdfa !important;
}
.mp-inline-edit-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.mp-inline-input {
    font-size: 13px !important;
    padding: 7px 10px !important;
}
.mp-inline-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-start;
}
.mp-inline-save,
.mp-inline-cancel {
    border: none;
    border-radius: var(--mp-radius-sm);
    padding: 4px 14px;
    min-width: 44px; min-height: 32px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
    line-height: 1.4;
    -webkit-appearance: none; appearance: none;
}
.mp-inline-save {
    background: var(--mp-teal);
    color: #fff;
}
.mp-inline-cancel {
    background: var(--mp-bg);
    color: var(--mp-text-muted);
    border: 1px solid var(--mp-border);
}
.mp-inline-saved {
    -webkit-animation: mp-save-flash 1.5s ease;
    animation: mp-save-flash 1.5s ease;
}
@-webkit-keyframes mp-save-flash { 0% { background-color: #d1fae5; } 100% { background-color: transparent; } }
@keyframes mp-save-flash { 0% { background-color: #d1fae5; } 100% { background-color: transparent; } }


/* ═══ FAMILY CARDS (Siblings & Relatives) ═══ */

.mp-family-card {
    background: var(--mp-bg);
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius);
    padding: 16px 20px;
    margin-bottom: 12px;
    transition: box-shadow 0.2s;
}
.mp-family-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--mp-border-light);
}
.mp-family-card__title {
    font-size: 13px;
    font-weight: 700;
    color: var(--mp-teal);
}
.mp-family-card__remove {
    background: #fef2f2;
    color: var(--mp-red);
    border: 1px solid #fca5a5;
    border-radius: var(--mp-radius-sm);
    padding: 2px 10px;
    min-width: 36px; min-height: 32px;
    font-size: 18px;
    cursor: pointer;
    line-height: 1.2;
    transition: background-color 0.15s, border-color 0.15s;
    -webkit-appearance: none; appearance: none;
}
.mp-spouse-block {
    background: var(--mp-accent-light);
    padding: 12px;
    border-radius: var(--mp-radius-sm);
    margin-top: 8px;
    border-top: 1px dashed var(--mp-border);
}
.mp-family-card .form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
    gap: 12px;
    margin-bottom: 8px;
}
.mp-family-card .form-row:last-child {
    margin-bottom: 0;
}
.mp-family-card label {
    font-size: 12px;
    font-weight: 600;
    color: var(--mp-text-secondary);
    margin-bottom: 4px;
    display: block;
}
.mp-subhead { margin: 18px 0 10px; font-size: 14px; color: var(--mp-teal); }
.mp-hint { color: var(--mp-text-muted); font-size: 12px; margin: -8px 0 14px; }


/* ═══ PHOTO PICKER ═══ */

.mp-photo-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 4px;
}
.mp-photo-item {
    position: relative;
    width: 90px;
    height: 110px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid var(--mp-border);
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
}
.mp-photo-item--selected {
    border-color: var(--mp-teal) !important;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.25), 0 4px 12px rgba(13, 148, 136, 0.15);
}
.mp-photo-item--selected .mp-photo-check {
    display: flex;
}
.mp-photo-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.mp-photo-check {
    display: none;
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    background: var(--mp-teal);
    color: #fff;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.mp-photo-badge {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.3px;
}
.mp-photo-none-inner {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: var(--mp-bg);
}
.mp-placeholder-box {
    padding: 20px; text-align: center;
    color: var(--mp-text-muted); font-size: 13px;
    background: var(--mp-bg);
    border-radius: var(--mp-radius-sm);
    border: 1px dashed var(--mp-border);
}


/* ═══ PHOTO EDITOR ═══ */

.mp-photo-editor {
    margin-top: 16px;
    padding: 20px;
    background: var(--mp-bg);
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius);
}
.mp-editor-preview-wrap {
    text-align: center;
    margin-bottom: 16px;
}
.mp-editor-canvas {
    width: 160px;
    height: 190px;
    margin: 0 auto;
    overflow: hidden;
    position: relative;
    cursor: -webkit-grab; cursor: grab;
    background: #e5e5e5;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-user-select: none; -moz-user-select: none; user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;           /* lets JS own drag + pinch without page scroll */
    -ms-touch-action: none;
    /* Safari: make border-radius clip the transformed child */
    -webkit-mask-image: -webkit-radial-gradient(white, black);
    isolation: isolate;
}
.mp-editor-canvas.is-dragging, .mp-editor-canvas:active {
    cursor: -webkit-grabbing; cursor: grabbing;
}
.mp-editor-canvas img {
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    pointer-events: none;
    -webkit-transition: -webkit-filter 0.3s ease; transition: filter 0.3s ease;
    will-change: transform;
    -webkit-user-drag: none;
}
.mp-editor-hint {
    font-size: 11px;
    color: var(--mp-text-muted);
    margin-top: 8px;
}
/* Shape classes applied to canvas */
.mp-editor-canvas.mp-shape-rounded { border-radius: 12px; }
.mp-editor-canvas.mp-shape-circle  { border-radius: 50%; width: 160px; height: 160px; }
.mp-editor-canvas.mp-shape-square  { border-radius: 0; }
.mp-editor-canvas.mp-shape-oval    { border-radius: 50%; width: 140px; height: 190px; }

.mp-editor-section {
    margin-bottom: 14px;
}
.mp-editor-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--mp-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 8px;
}

/* Shape buttons */
.mp-shape-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.mp-shape-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border: 2px solid var(--mp-border);
    border-radius: var(--mp-radius-sm);
    background: #fff;
    color: var(--mp-text-muted);
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background-color 0.2s;
    -webkit-appearance: none; appearance: none; padding: 0;
}
.mp-shape-btn--active {
    border-color: var(--mp-teal);
    background: var(--mp-teal-light);
    color: var(--mp-teal);
}

/* Sliders — WebKit/Blink + Firefox */
.mp-editor-sliders {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}
.mp-slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.mp-slider-label {
    font-size: 12px;
    color: var(--mp-text-secondary);
    width: 80px;
    flex-shrink: 0;
}
.mp-slider {
    -webkit-box-flex: 1; -ms-flex: 1 1 auto; flex: 1 1 auto;
    min-width: 0;
    height: 20px;           /* tall hit area; the track itself is drawn thin */
    margin: 0;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: transparent;
    outline: none;
    cursor: pointer;
}
.mp-slider::-webkit-slider-runnable-track {
    height: 4px; background: var(--mp-border); border-radius: 2px;
}
.mp-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    margin-top: -6px;
    border-radius: 50%;
    background: var(--mp-teal);
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    cursor: pointer;
}
.mp-slider::-moz-range-track {
    height: 4px; background: var(--mp-border); border-radius: 2px; border: 0;
}
.mp-slider::-moz-range-progress {
    height: 4px; background: var(--mp-teal); border-radius: 2px;
}
.mp-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--mp-teal);
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    cursor: pointer;
}
.mp-slider:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(13,148,136,0.25); }
.mp-slider-value {
    font-size: 11px;
    color: var(--mp-text-muted);
    width: 40px;
    text-align: right;
    flex-shrink: 0;
}

/* Preset buttons */
.mp-editor-presets {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.mp-preset-btn {
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid var(--mp-border);
    border-radius: 100px;
    background: #fff;
    color: var(--mp-text-secondary);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background-color 0.15s;
    -webkit-appearance: none; appearance: none;
}
.mp-preset-btn--active {
    border-color: var(--mp-teal);
    background: var(--mp-teal);
    color: #fff;
}


/* ═══ IMPORTED DATA (edit form) ═══ */

.mp-import-row { gap: 8px; }
.mp-import-row__text { min-width: 0; overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; }


/* ═══════════════════════════════════════════════════════
   HOVER — only for devices that can really hover.
   (On phones, :hover "sticks" after a tap.)
   ═══════════════════════════════════════════════════════ */

@media (hover: hover) and (pointer: fine) {
    .mp-section__header--toggle:hover { background: var(--mp-bg); }
    .mp-table tr:hover td { background: #fdfcfb; }
    .mp-profile-card:hover { box-shadow: var(--mp-shadow-md); -webkit-transform: translateY(-2px); transform: translateY(-2px); }
    .mp-btn--primary:hover { background: var(--mp-accent-hover); }
    .mp-btn--secondary:hover { background: var(--mp-border-light); }
    .mp-btn--ghost:hover { background: var(--mp-bg); }
    .mp-btn--teal:hover { background: #0f766e; }
    .mp-btn--danger:hover { background: rgba(220,53,69,0.08); }
    .matrimony-btn-primary:hover { background: var(--mp-accent-hover); }
    .matrimony-btn-secondary:hover { background: var(--mp-border-light); }
    .mp-pagination button:hover:not(:disabled) { background: var(--mp-bg); }
    .mp-share-btn--whatsapp:hover {
        background-color: #1da851 !important;
        -webkit-transform: translateY(-1px); transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
    }
    .mp-share-btn--house:hover {
        background-color: var(--mp-accent-hover) !important;
        -webkit-transform: translateY(-1px); transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(180, 83, 9, 0.25);
    }
    .mp-share-modal__close:hover { color: var(--mp-text); background: rgba(0,0,0,0.05); }
    .mp-view-head__photo-btn:hover { -webkit-transform: scale(1.05); transform: scale(1.05); }
    .mp-gallery-upload:hover { border-color: var(--mp-accent); background: rgba(13,148,136,0.03); }
    .mp-gallery-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.1); }
    .mp-share-house-item:hover { background: var(--mp-teal-light); }
    .mp-design-card:hover {
        border-color: var(--mp-teal);
        box-shadow: 0 4px 12px rgba(13, 148, 136, 0.15);
        -webkit-transform: translateY(-2px); transform: translateY(-2px);
    }
    .mp-inline-row:hover { background: #fdfcfa; }
    .mp-inline-row:hover .mp-inline-edit-btn { opacity: 1; }
    .mp-inline-edit-btn:hover { background: var(--mp-teal); color: #fff; }
    .mp-inline-save:hover { background: #0f766e; }
    .mp-inline-cancel:hover { background: #fef2f2; color: var(--mp-red); border-color: #fca5a5; }
    .mp-family-card:hover { box-shadow: var(--mp-shadow); }
    .mp-family-card__remove:hover { background: #fee2e2; border-color: var(--mp-red); }
    .mp-photo-item:hover {
        border-color: var(--mp-teal);
        -webkit-transform: scale(1.05); transform: scale(1.05);
        box-shadow: 0 4px 12px rgba(13, 148, 136, 0.2);
    }
    .mp-shape-btn:hover { border-color: var(--mp-teal); color: var(--mp-teal); }
    .mp-preset-btn:hover { border-color: var(--mp-teal); color: var(--mp-teal); background: var(--mp-teal-light); }
}

/* ═══ TOUCH / COARSE POINTER — bigger targets, always-visible controls ═══ */

@media (hover: none), (pointer: coarse) {
    .mp-inline-edit-btn { opacity: 1; width: 34px; height: 34px; }
    .mp-btn { min-height: 40px; }
    .mp-btn--sm { min-height: 36px; padding: 6px 14px; }
    .mp-btn--xs { min-height: 32px; padding: 4px 10px; }
    .matrimony-btn { min-height: 44px; }
    .mp-slider::-webkit-slider-thumb { width: 24px; height: 24px; margin-top: -10px; }
    .mp-slider::-moz-range-thumb { width: 22px; height: 22px; }
    .mp-slider { height: 32px; }
    .mp-pdf-toggle { display: inline-block; padding: 5px 10px !important; }
    .mp-gallery-upload__label { padding: 24px 16px; }
}


/* ═══════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════ */

/* ── Tablet & below ── */
@media (max-width: 768px) {
    .mp-page { padding: 0 12px 48px; }
    .matrimony-container { padding: 4px 12px 20px; }

    .mp-hero { padding: 32px 24px; margin-bottom: 20px; }
    .mp-hero__title { font-size: 22px; }
    .mp-hero::before { width: 260px; height: 260px; }

    .mp-section { margin-bottom: 16px; }
    .mp-section__header { padding: 16px; flex-direction: column; align-items: flex-start; }
    .mp-section__header--toggle { flex-direction: row; align-items: center; }
    .mp-section__subtitle { margin-left: 0; }
    .mp-filter-form { padding: 16px; }
    .mp-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mp-field--actions { grid-column: 1 / -1; }
    .mp-field--actions .mp-btn { -webkit-box-flex: 1; -ms-flex: 1 1 0%; flex: 1 1 0%; }
    .mp-profiles-grid { grid-template-columns: 1fr; padding: 16px; }

    /* iOS Safari zooms the page when a focused input is < 16px — prevent it */
    .mp-input, .matrimony-input, .mp-inline-input,
    .mp-share-message-wrap .mp-input { font-size: 16px !important; min-height: 44px; }
    textarea.mp-input, textarea.matrimony-input { min-height: 88px; }

    /* Form pages */
    .matrimony-header h2 { font-size: 20px; }
    .matrimony-profile-form { padding: 18px 14px; padding-bottom: calc(var(--mp-bar-h) + 24px + var(--mp-safe-bottom)); }
    .matrimony-form-section { margin-bottom: 20px; padding-bottom: 20px; }
    .matrimony-profile-form .form-row { grid-template-columns: 1fr; gap: 12px; }
    .matrimony-form-actions { padding: 10px 12px; padding-bottom: calc(10px + var(--mp-safe-bottom)); gap: 10px; }
    .matrimony-form-actions .matrimony-btn { -webkit-box-flex: 1; -ms-flex: 1 1 0%; flex: 1 1 0%; max-width: 260px; }
    .mp-family-card { padding: 14px; }
    .mp-family-card .form-row { grid-template-columns: 1fr; }
    .mp-photo-editor { padding: 16px 12px; }

    /* ── List tables → stacked cards (no horizontal scroll on phones) ── */
    .mp-table--responsive,
    .mp-table--responsive tbody { display: block; width: 100%; }
    .mp-table--responsive thead { display: none; }
    .mp-table--responsive tr {
        display: grid;
        grid-template-columns: 48px minmax(0, 1fr);
        -webkit-column-gap: 12px; column-gap: 12px;
        row-gap: 6px;
        padding: 14px 16px;
        border-bottom: 1px solid var(--mp-border-light);
        align-items: center;
    }
    .mp-table--responsive tr:last-child { border-bottom: none; }
    .mp-table--responsive td {
        display: block;
        padding: 0;
        border: 0 !important;
        font-size: 13px;
        min-width: 0;
        grid-column: 1 / -1;
    }
    .mp-table--responsive td.mp-td-photo { grid-column: 1; grid-row: 1; }
    .mp-table--responsive td.mp-td-name  { grid-column: 2; grid-row: 1; }
    .mp-table--responsive td[data-label]:not(.mp-td-name):not(.mp-td-photo):not(.mp-actions) {
        display: flex; gap: 8px; align-items: baseline;
        padding-left: 60px;
    }
    .mp-table--responsive td[data-label]:not(.mp-td-name):not(.mp-td-photo):not(.mp-actions)::before {
        content: attr(data-label);
        flex: 0 0 auto;
        font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
        color: var(--mp-text-muted);
        min-width: 84px;
    }
    .mp-table--responsive td .mp-meta { display: inline; margin: 0 0 0 6px; }
    .mp-table--responsive td.mp-td-name .mp-meta { display: block; margin: 2px 0 0; }
    .mp-table--responsive td.mp-actions {
        text-align: left; white-space: normal;
        display: flex; flex-wrap: wrap; gap: 8px;
        padding-top: 6px;
    }
    .mp-table--responsive td.mp-actions .mp-btn { margin: 0; -webkit-box-flex: 1; -ms-flex: 1 1 auto; flex: 1 1 auto; }
    .mp-table--responsive tr:hover td { background: transparent; }

    /* Profile view */
    .mp-view-body { padding: 14px; }
    .mp-view-head { gap: 16px; padding: 16px; }
    .mp-view-head__name { font-size: 20px; }

    /* Share bar */
    .mp-share-bar { padding: 16px; }
}

/* ── Phones ── */
@media (max-width: 600px) {
    .mp-hero { padding: 24px 18px; border-radius: 8px; }
    .mp-hero__title { font-size: 20px; }
    .mp-hero__subtitle { font-size: 13px; }

    /* Profile view header: centred stack */
    .mp-view-topbar { flex-direction: column; align-items: stretch; }
    .mp-view-actions .mp-btn { -webkit-box-flex: 1; -ms-flex: 1 1 0%; flex: 1 1 0%; }
    .mp-view-head { flex-direction: column; text-align: center; }
    .mp-view-head__info { -ms-flex-preferred-size: auto; flex-basis: auto; width: 100%; }
    .mp-view-head__chips { justify-content: center; }
    .mp-view-head__photo .mp-pdf-toggle { display: block; }

    /* Key/value table: label on top, value below. !important beats inline styles. */
    .mp-inline-table, .mp-inline-table tbody { display: block; width: 100%; }
    .mp-inline-table tr { display: block; }
    .mp-inline-table th,
    .mp-inline-table td {
        display: block;
        width: auto !important;
        text-align: left;
    }
    .mp-inline-table tr.mp-inline-row > th {
        padding: 10px 12px 2px !important;
        border-bottom: 0 !important;
        font-size: 12px !important;
    }
    .mp-inline-table tr.mp-inline-row > td {
        padding: 2px 12px 10px !important;
        font-size: 14px;
    }
    .mp-inline-table tr.mp-inline-row[data-field] > td { padding-right: 52px !important; }
    .mp-inline-table tr.mp-inline-row[data-field] .mp-inline-edit-btn { top: auto; bottom: 8px; -webkit-transform: none; transform: none; }
    .mp-inline-table .mp-pdf-toggle { float: none !important; display: inline-block; margin: 6px 0 0 !important; }
    .mp-inline-table .mp-section-header > td .mp-pdf-toggle { margin-left: 8px !important; }

    /* Share bar */
    .mp-share-bar {
        flex-direction: column;
        align-items: stretch; text-align: center;
    }
    .mp-share-bar__actions { justify-content: center; }
    .mp-share-btn {
        -webkit-box-flex: 1; -ms-flex: 1 1 0%; flex: 1 1 0%;
        justify-content: center; min-width: 0;
    }

    /* Modals → bottom sheets */
    .mp-share-modal { align-items: flex-end; padding: 0; }
    .mp-share-modal__dialog {
        max-width: 100% !important;
        width: 100%;
        max-height: 92vh; max-height: 92dvh;
        border-radius: 14px 14px 0 0;
        -webkit-animation: mp-sheet-in 0.25s ease; animation: mp-sheet-in 0.25s ease;
    }
    .mp-share-modal__header { padding: 14px 16px; }
    .mp-share-modal__body { padding: 16px; }
    .mp-share-modal__footer {
        padding: 12px 16px;
        padding-bottom: calc(12px + var(--mp-safe-bottom));
    }
    .mp-share-modal__footer > .mp-btn { -webkit-box-flex: 1; -ms-flex: 1 1 0%; flex: 1 1 0%; }

    /* PDF preview → full screen */
    .mp-share-modal__dialog.mp-preview-dialog {
        height: 100vh; height: 100dvh;
        max-height: none;
        border-radius: 0;
    }
    .mp-preview-body { padding: 6px !important; }
    .mp-share-modal__footer.mp-preview-footer {
        flex-direction: column-reverse;
        align-items: stretch;
    }
    .mp-preview-footer > .mp-btn { width: 100%; }
    .mp-preview-actions { justify-content: center; }
    .mp-preview-actions .mp-share-btn {
        -webkit-box-flex: 1; -ms-flex: 1 1 0%; flex: 1 1 0%;
        justify-content: center;
        min-width: 0; font-size: 12px;
        padding: 10px 8px !important;
    }

    /* Enlarged photo: keep the close button on-screen */
    .mp-share-modal.mp-enlarge { align-items: center; padding: 12px; }
    .mp-enlarge__close { top: 8px; right: 8px; }
    .mp-enlarge__img, .mp-enlarge__wrap { max-width: 94vw; }

    /* Gallery */
    .mp-gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mp-gallery-card__img-wrap { height: 120px; }
}

/* ── Small phones ── */
@media (max-width: 480px) {
    .mp-filter-grid { grid-template-columns: 1fr; }
    .mp-profile-card__body { grid-template-columns: 1fr; }
    .mp-design-grid { gap: 10px; }
    .mp-design-preview { height: 80px; }
    .mp-design-label { font-size: 12px; padding: 6px 8px 1px; }
    .mp-design-desc { font-size: 10px; padding: 0 8px 4px; }

    .mp-table--responsive td[data-label]:not(.mp-td-name):not(.mp-td-photo):not(.mp-actions) { padding-left: 0; }

    .mp-photo-grid { gap: 10px; }
    .mp-photo-item { width: 80px; height: 98px; }

    .mp-slider-label { width: 68px; font-size: 11px; }
    .mp-editor-presets { gap: 4px; }
    .mp-preset-btn { padding: 6px 10px; font-size: 11px; }

    .mp-import-row { -ms-flex-wrap: wrap !important; flex-wrap: wrap !important; }
    .mp-import-row__btn { margin-left: 0 !important; }

    .matrimony-header { flex-direction: column; align-items: stretch; }
    .matrimony-header .matrimony-btn { width: 100%; }
}

/* ── Very narrow (≤ 360px, e.g. older Androids, iPhone SE 1st gen) ── */
@media (max-width: 360px) {
    .mp-design-grid { grid-template-columns: 1fr; }
    .mp-gallery-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .mp-view-head__img, .mp-view-head__placeholder { width: 100px; height: 100px; }
    .mp-preview-actions .mp-share-btn { -ms-flex-preferred-size: 100%; flex-basis: 100%; }
}

/* ── Landscape phones: short viewport ── */
@media (max-height: 480px) and (orientation: landscape) {
    .mp-share-modal__dialog { max-height: 96vh; max-height: 96dvh; }
    .matrimony-form-actions { padding-top: 6px; padding-bottom: calc(6px + var(--mp-safe-bottom)); }
}


/* ═══ Safari < 14.1 has no flex `gap` → margin fallback ═══
   (aspect-ratio arrived in the same Safari generation; this targets only old engines) */
@supports not (aspect-ratio: 1 / 1) {
    .mp-share-bar__actions > *, .mp-preview-actions > *, .mp-view-actions > *,
    .matrimony-form-actions > *, .mp-field--actions > *, .mp-photo-grid > *,
    .mp-shape-options > *, .mp-editor-presets > *, .mp-view-head__chips > *,
    .mp-share-modal__footer > *, .mp-gallery-card__actions > *,
    .mp-table--responsive td.mp-actions > * { margin: 4px; }
    .mp-range > * + * { margin-left: 10px; }
}


/* ═══ Reduced motion ═══ */
@media (prefers-reduced-motion: reduce) {
    .mp-page *, .matrimony-container *, .mp-share-modal, .mp-share-modal * {
        -webkit-animation-duration: 0.01ms !important; animation-duration: 0.01ms !important;
        -webkit-animation-iteration-count: 1 !important; animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .mp-loading__spinner { -webkit-animation-duration: 1.5s !important; animation-duration: 1.5s !important; animation-iteration-count: infinite !important; }
}


@media print {
    .mp-hero, .mp-section--filters, .mp-profile-card__footer,
    .mp-actions, .matrimony-form-actions, .mp-share-bar, .mp-view-actions,
    .mp-inline-edit-btn, .mp-pdf-toggle { display: none !important; }
}
