/* ═══════════════════════════════════════════════════════════════
   PersianLocal — WordPress Dating Plugin Styles
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300..700;1,9..40,300..700&family=Playfair+Display:wght@500;700&display=swap');

:root {
    --fm-primary: #e84393;
    --fm-primary-dark: #c0357a;
    --fm-primary-light: #fd79a8;
    --fm-accent: #6c5ce7;
    --fm-accent-light: #a29bfe;
    --fm-success: #00b894;
    --fm-danger: #d63031;
    --fm-warning: #fdcb6e;
    --fm-dark: #2d3436;
    --fm-mid: #636e72;
    --fm-light: #b2bec3;
    --fm-lighter: #dfe6e9;
    --fm-bg: #f8f9fa;
    --fm-white: #ffffff;
    --fm-card-shadow: 0 2px 16px rgba(0,0,0,.07);
    --fm-card-hover-shadow: 0 8px 32px rgba(232,67,147,.15);
    --fm-radius: 12px;
    --fm-radius-sm: 8px;
    --fm-radius-lg: 20px;
    --fm-font: 'DM Sans', -apple-system, sans-serif;
    --fm-font-display: 'Playfair Display', Georgia, serif;
    --fm-transition: .2s cubic-bezier(.4,0,.2,1);
}

/* ─── Reset & Base ─────────────────────────────────────────────── */

.fm-wrap {
    font-family: var(--fm-font);
    color: var(--fm-dark);
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 20px;
    line-height: 1.6;
}

.fm-wrap *, .fm-wrap *::before, .fm-wrap *::after {
    box-sizing: border-box;
}

.fm-wrap h2 {
    font-family: var(--fm-font-display);
    font-weight: 700;
    font-size: 2rem;
    margin: 0 0 8px;
    color: var(--fm-dark);
}

.fm-wrap h3 {
    font-family: var(--fm-font-display);
    font-weight: 500;
    font-size: 1.3rem;
    margin: 0 0 16px;
    color: var(--fm-dark);
    padding-bottom: 8px;
    border-bottom: 2px solid var(--fm-lighter);
}

/* ─── Navigation Bar ───────────────────────────────────────────── */

.fm-nav {
    background: var(--fm-white);
    border-bottom: 1px solid var(--fm-lighter);
    margin-bottom: 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 8px rgba(0,0,0,.04);
}

/* Push down if WP admin bar is showing */
.admin-bar .fm-nav {
    top: 32px;
}

.fm-nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    padding: 0 16px;
    height: 56px;
    gap: 8px;
}

.fm-nav-logo {
    font-family: var(--fm-font-display);
    font-weight: 700;
    font-size: 1.25rem;
    background: linear-gradient(135deg, var(--fm-primary), var(--fm-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
    margin-right: 12px;
    white-space: nowrap;
}

.fm-nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.fm-nav-links::-webkit-scrollbar {
    display: none;
}

.fm-nav-link {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 14px;
    border-radius: var(--fm-radius-sm);
    text-decoration: none;
    color: var(--fm-mid);
    font-weight: 500;
    font-size: .9rem;
    white-space: nowrap;
    transition: all var(--fm-transition);
    position: relative;
}

.fm-nav-link:hover {
    background: var(--fm-bg);
    color: var(--fm-primary);
}

.fm-nav-link.fm-nav-active {
    background: linear-gradient(135deg, rgba(232,67,147,.08), rgba(108,92,231,.08));
    color: var(--fm-primary);
    font-weight: 600;
}

.fm-nav-icon {
    font-size: 1rem;
    line-height: 1;
}

.fm-nav-badge {
    background: var(--fm-primary);
    color: var(--fm-white);
    font-size: .65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    position: absolute;
    top: 2px;
    right: 2px;
}

.fm-nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    flex-shrink: 0;
}

.fm-nav-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--fm-lighter);
}

.fm-nav-logout {
    font-size: .82rem;
    color: var(--fm-light);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--fm-radius-sm);
    border: 1px solid var(--fm-lighter);
    transition: all var(--fm-transition);
}

.fm-nav-logout:hover {
    color: var(--fm-danger);
    border-color: var(--fm-danger);
}

/* Mobile nav */
@media (max-width: 768px) {
    .fm-nav-inner { height: 50px; padding: 0 10px; }
    .fm-nav-logo { font-size: 1.1rem; margin-right: 6px; }
    .fm-nav-label { display: none; }
    .fm-nav-link { padding: 8px 10px; }
    .fm-nav-icon { font-size: 1.2rem; }
    .fm-nav-logout { font-size: .75rem; padding: 5px 8px; }
    .admin-bar .fm-nav { top: 46px; }
}

@media (max-width: 480px) {
    .fm-nav-logo { display: none; }
    .fm-nav-links { justify-content: space-around; }
    .fm-nav-link { padding: 8px 8px; }
}

.fm-wrap h4 {
    font-family: var(--fm-font);
    font-weight: 600;
    font-size: 1.05rem;
    margin: 0 0 4px;
}

.fm-wrap p {
    margin: 0 0 12px;
}

.fm-wrap a {
    color: var(--fm-primary);
    text-decoration: none;
    transition: color var(--fm-transition);
}

.fm-wrap a:hover {
    color: var(--fm-primary-dark);
}

.fm-subtitle {
    color: var(--fm-mid);
    font-size: 1.05rem;
    margin-bottom: 24px !important;
}

/* ─── Buttons ──────────────────────────────────────────────────── */

.fm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 24px;
    border: none;
    border-radius: var(--fm-radius-sm);
    font-family: var(--fm-font);
    font-weight: 600;
    font-size: .95rem;
    cursor: pointer;
    transition: all var(--fm-transition);
    text-decoration: none;
    white-space: nowrap;
}

.fm-btn:hover { transform: translateY(-1px); }
.fm-btn:active { transform: translateY(0); }

.fm-btn-primary {
    background: linear-gradient(135deg, var(--fm-primary), var(--fm-primary-dark));
    color: var(--fm-white);
    box-shadow: 0 4px 14px rgba(232,67,147,.3);
}
.fm-btn-primary:hover {
    box-shadow: 0 6px 20px rgba(232,67,147,.45);
    color: var(--fm-white);
}

.fm-btn-secondary {
    background: var(--fm-white);
    color: var(--fm-dark);
    border: 2px solid var(--fm-lighter);
}
.fm-btn-secondary:hover {
    border-color: var(--fm-primary-light);
    color: var(--fm-primary);
}

.fm-btn-accent {
    background: linear-gradient(135deg, var(--fm-accent), #5f3dc4);
    color: var(--fm-white);
    box-shadow: 0 4px 14px rgba(108,92,231,.3);
}
.fm-btn-accent:hover {
    box-shadow: 0 6px 20px rgba(108,92,231,.45);
    color: var(--fm-white);
}

.fm-btn-danger {
    background: var(--fm-white);
    color: var(--fm-danger);
    border: 1px solid var(--fm-danger);
}
.fm-btn-danger:hover {
    background: var(--fm-danger);
    color: var(--fm-white);
}

.fm-btn-sm { padding: 6px 16px; font-size: .85rem; }
.fm-btn-lg { padding: 14px 36px; font-size: 1.05rem; }

/* ─── Messages / Alerts ────────────────────────────────────────── */

.fm-msg {
    padding: 12px 20px;
    border-radius: var(--fm-radius-sm);
    margin-bottom: 20px;
    font-weight: 500;
}
.fm-msg.fm-success { background: #d4edda; color: #155724; }
.fm-msg.fm-error { background: #f8d7da; color: #721c24; }

.fm-loading {
    text-align: center;
    padding: 40px;
    color: var(--fm-mid);
    font-style: italic;
}

.fm-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--fm-mid);
}
.fm-empty-state p { font-size: 1.1rem; margin-bottom: 20px; }

/* ─── Forms ────────────────────────────────────────────────────── */

.fm-field {
    margin-bottom: 16px;
    flex: 1;
    min-width: 0;
}

.fm-field label {
    display: block;
    font-weight: 600;
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--fm-mid);
    margin-bottom: 6px;
}

.fm-field input[type="text"],
.fm-field input[type="number"],
.fm-field input[type="date"],
.fm-field input[type="email"],
.fm-field select,
.fm-field textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--fm-lighter);
    border-radius: var(--fm-radius-sm);
    font-family: var(--fm-font);
    font-size: .95rem;
    color: var(--fm-dark);
    background: var(--fm-white);
    transition: border-color var(--fm-transition);
}

.fm-field input:focus,
.fm-field select:focus,
.fm-field textarea:focus {
    outline: none;
    border-color: var(--fm-primary-light);
    box-shadow: 0 0 0 3px rgba(232,67,147,.1);
}

.fm-field textarea { resize: vertical; }

.fm-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

/* ─── Login Prompt ─────────────────────────────────────────────── */

.fm-login-prompt {
    text-align: center;
    padding: 80px 20px;
    background: linear-gradient(135deg, #ffeef5, #f0e6ff);
    border-radius: var(--fm-radius-lg);
}
.fm-login-prompt h2 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--fm-primary), var(--fm-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.fm-login-prompt p {
    font-size: 1.15rem;
    color: var(--fm-mid);
    margin-bottom: 24px;
}
.fm-login-prompt-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ─── Auth Pages (Login / Register) ────────────────────────────── */

.fm-auth-page {
    display: flex;
    justify-content: center;
    padding: 40px 16px;
    min-height: 60vh;
}

.fm-auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--fm-white);
    border-radius: var(--fm-radius-lg);
    box-shadow: 0 4px 24px rgba(0,0,0,.08);
    overflow: hidden;
}

.fm-auth-header {
    background: linear-gradient(135deg, var(--fm-primary), var(--fm-accent));
    padding: 36px 32px 28px;
    text-align: center;
}

.fm-auth-header h2 {
    font-family: var(--fm-font-display);
    font-size: 2rem;
    font-weight: 700;
    color: var(--fm-white);
    margin: 0 0 4px;
}

.fm-auth-header p {
    color: rgba(255,255,255,.8);
    font-size: 1rem;
    margin: 0;
}

.fm-auth-error {
    background: #fde8e8;
    color: #c0392b;
    padding: 12px 20px;
    margin: 20px 24px 0;
    border-radius: var(--fm-radius-sm);
    font-size: .95rem;
    font-weight: 500;
}

.fm-auth-form {
    padding: 28px 32px 20px;
}

.fm-auth-form .fm-field {
    margin-bottom: 18px;
}

.fm-auth-form .fm-field label {
    display: block;
    font-weight: 600;
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--fm-mid);
    margin-bottom: 6px;
}

.fm-auth-form .fm-field input {
    width: 100%;
    padding: 13px 16px;
    border: 2px solid var(--fm-lighter);
    border-radius: var(--fm-radius-sm);
    font-family: var(--fm-font);
    font-size: 16px;
    color: var(--fm-dark);
    background: var(--fm-bg);
    transition: border-color var(--fm-transition);
}

.fm-auth-form .fm-field input:focus {
    outline: none;
    border-color: var(--fm-primary-light);
    box-shadow: 0 0 0 3px rgba(232,67,147,.1);
}

.fm-auth-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    font-size: .9rem;
}

.fm-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--fm-mid);
    cursor: pointer;
}

.fm-checkbox input {
    width: auto;
    margin: 0;
}

.fm-forgot-link {
    color: var(--fm-primary);
    text-decoration: none;
    font-size: .9rem;
}

.fm-forgot-link:hover {
    text-decoration: underline;
}

.fm-btn-full {
    width: 100%;
    justify-content: center;
}

.fm-auth-terms {
    text-align: center;
    font-size: .8rem;
    color: var(--fm-light);
    margin-top: 16px;
}

.fm-auth-footer {
    text-align: center;
    padding: 20px 32px 28px;
    border-top: 1px solid var(--fm-lighter);
    font-size: .95rem;
    color: var(--fm-mid);
}

.fm-auth-footer a {
    color: var(--fm-primary);
    font-weight: 600;
    text-decoration: none;
}

.fm-auth-footer a:hover {
    text-decoration: underline;
}

@media (max-width: 480px) {
    .fm-auth-card { border-radius: var(--fm-radius); }
    .fm-auth-header { padding: 28px 20px 22px; }
    .fm-auth-header h2 { font-size: 1.6rem; }
    .fm-auth-form { padding: 24px 20px 16px; }
    .fm-auth-footer { padding: 16px 20px 24px; }
    .fm-auth-options { flex-direction: column; gap: 10px; align-items: flex-start; }
}

/* ─── Dashboard ────────────────────────────────────────────────── */

.fm-welcome-banner {
    text-align: center;
    padding: 80px 30px;
    background: linear-gradient(135deg, #ffeef5, #f0e6ff);
    border-radius: var(--fm-radius-lg);
}
.fm-welcome-banner h2 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--fm-primary), var(--fm-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.fm-welcome-banner p {
    font-size: 1.15rem;
    color: var(--fm-mid);
    margin-bottom: 28px;
}

.fm-dash-header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 28px;
    background: var(--fm-white);
    border-radius: var(--fm-radius-lg);
    box-shadow: var(--fm-card-shadow);
    margin-bottom: 28px;
}

.fm-dash-avatar img,
.fm-avatar-placeholder {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
}
.fm-avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--fm-primary-light), var(--fm-accent-light));
    color: var(--fm-white);
    font-size: 2rem;
    font-weight: 700;
}

.fm-dash-info .fm-tagline {
    color: var(--fm-mid);
    font-style: italic;
}

.fm-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.fm-stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
    background: var(--fm-white);
    border-radius: var(--fm-radius);
    box-shadow: var(--fm-card-shadow);
    text-decoration: none;
    color: var(--fm-dark);
    transition: all var(--fm-transition);
}
.fm-stat-card:hover {
    box-shadow: var(--fm-card-hover-shadow);
    transform: translateY(-2px);
    color: var(--fm-dark);
}

.fm-stat-icon { font-size: 1.8rem; margin-bottom: 8px; }
.fm-stat-num { font-size: 2rem; font-weight: 700; line-height: 1; }
.fm-stat-label { font-size: .85rem; color: var(--fm-mid); margin-top: 4px; }

.fm-dash-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* ─── Profile Edit ─────────────────────────────────────────────── */

.fm-edit-profile .fm-form-grid {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.fm-section {
    background: var(--fm-white);
    padding: 28px;
    border-radius: var(--fm-radius);
    box-shadow: var(--fm-card-shadow);
}

.fm-photo-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.fm-main-photo {
    display: flex;
    align-items: flex-end;
    gap: 16px;
}

.fm-photo-frame {
    width: 180px;
    height: 220px;
    border-radius: var(--fm-radius);
    background: var(--fm-lighter) center/cover no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px dashed var(--fm-light);
    cursor: pointer;
    transition: all var(--fm-transition);
    overflow: hidden;
}
.fm-photo-frame:hover {
    border-color: var(--fm-primary-light);
}
.fm-photo-placeholder {
    font-size: 1.1rem;
    color: var(--fm-mid);
}

.fm-gallery-grid {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.fm-gallery-grid .fm-gallery-thumb {
    width: 100px;
    height: 100px;
    border-radius: var(--fm-radius-sm);
    background: center/cover no-repeat;
    position: relative;
}
.fm-gallery-grid .fm-gallery-thumb .fm-remove-photo {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: .75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fm-form-actions {
    text-align: center;
    padding-top: 12px;
}

/* ─── Browse / Profile Grid ────────────────────────────────────── */

.fm-browse-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.fm-filters {
    background: var(--fm-white);
    padding: 20px 24px;
    border-radius: var(--fm-radius);
    box-shadow: var(--fm-card-shadow);
    margin-bottom: 24px;
}

.fm-filter-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.fm-filter-row .fm-field { min-width: 160px; }

.fm-range-pair {
    display: flex;
    align-items: center;
    gap: 8px;
}
.fm-range-pair input { width: 70px !important; }

.fm-profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.fm-profile-card {
    background: var(--fm-white);
    border-radius: var(--fm-radius);
    overflow: hidden;
    box-shadow: var(--fm-card-shadow);
    transition: all var(--fm-transition);
    display: flex;
    flex-direction: column;
}
.fm-profile-card:hover {
    box-shadow: var(--fm-card-hover-shadow);
    transform: translateY(-3px);
}

.fm-profile-card a {
    text-decoration: none;
    color: inherit;
}

.fm-card-photo {
    width: 100%;
    height: 300px;
    background: var(--fm-lighter) center/cover no-repeat;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.fm-card-initial {
    font-size: 4rem;
    color: var(--fm-light);
    font-weight: 700;
}

.fm-card-compat {
    position: absolute;
    top: 12px;
    right: 12px;
    background: linear-gradient(135deg, var(--fm-primary), var(--fm-accent));
    color: var(--fm-white);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: .8rem;
    font-weight: 700;
}

.fm-card-info {
    padding: 16px 20px 10px;
}
.fm-card-info h4 { color: var(--fm-dark); }
.fm-card-info p { color: var(--fm-mid); font-size: .9rem; margin: 0; }

.fm-profile-card > .fm-btn {
    margin: 0 16px 16px;
}

/* ─── View Profile ─────────────────────────────────────────────── */

.fm-vp-header {
    display: flex;
    gap: 32px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.fm-vp-photo-section { flex-shrink: 0; }

.fm-vp-main-photo {
    width: 320px;
    height: 400px;
    border-radius: var(--fm-radius-lg);
    background: var(--fm-lighter) center/cover no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.fm-avatar-large {
    font-size: 6rem;
    color: var(--fm-light);
    font-weight: 700;
}

.fm-vp-gallery {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.fm-vp-thumb {
    width: 72px;
    height: 72px;
    border-radius: var(--fm-radius-sm);
    background: center/cover no-repeat;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color var(--fm-transition);
}
.fm-vp-thumb:hover { border-color: var(--fm-primary-light); }

.fm-vp-info {
    flex: 1;
    min-width: 260px;
}
.fm-vp-info h2 { font-size: 2.4rem; margin-bottom: 4px; }
.fm-vp-info .fm-tagline {
    font-size: 1.1rem;
    color: var(--fm-mid);
    font-style: italic;
    margin-bottom: 8px;
}
.fm-vp-meta { color: var(--fm-mid); margin-bottom: 20px !important; }

.fm-compat-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    border-radius: 30px;
    margin-bottom: 20px;
    font-weight: 600;
}
.fm-compat-high { background: #d4edda; color: #155724; }
.fm-compat-mid { background: #fff3cd; color: #856404; }
.fm-compat-low { background: #f8d7da; color: #721c24; }
.fm-compat-score { font-size: 1.4rem; font-weight: 700; }
.fm-compat-label { font-size: .85rem; }

.fm-vp-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.fm-like-btn.fm-liked {
    background: var(--fm-primary-light);
    color: var(--fm-white);
}

.fm-match-notice {
    background: linear-gradient(135deg, #fff9db, #ffe3e3);
    padding: 12px 20px;
    border-radius: var(--fm-radius-sm);
    font-weight: 600;
    color: var(--fm-primary-dark);
}

.fm-vp-body { max-width: 800px; }

.fm-vp-section {
    background: var(--fm-white);
    padding: 24px;
    border-radius: var(--fm-radius);
    box-shadow: var(--fm-card-shadow);
    margin-bottom: 20px;
}

.fm-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}
.fm-detail-item {
    display: flex;
    flex-direction: column;
}
.fm-detail-label {
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--fm-mid);
    font-weight: 600;
}
.fm-detail-value {
    font-weight: 500;
    color: var(--fm-dark);
}

.fm-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.fm-tag {
    background: linear-gradient(135deg, #ffeef5, #f0e6ff);
    color: var(--fm-primary-dark);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: .88rem;
    font-weight: 500;
}

/* ─── Messages ─────────────────────────────────────────────────── */

.fm-messages-wrap {
    display: flex;
    gap: 0;
    min-height: 600px;
    background: var(--fm-white);
    border-radius: var(--fm-radius-lg);
    box-shadow: var(--fm-card-shadow);
    overflow: hidden;
}

.fm-msg-sidebar {
    width: 320px;
    border-right: 1px solid var(--fm-lighter);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.fm-msg-sidebar h3 {
    padding: 20px 20px 12px;
    margin: 0;
    border-bottom: none;
}

.fm-conv-list {
    overflow-y: auto;
    flex: 1;
}

.fm-conv-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    cursor: pointer;
    border-bottom: 1px solid var(--fm-lighter);
    transition: background var(--fm-transition);
}
.fm-conv-item:hover { background: var(--fm-bg); }
.fm-conv-item.active { background: #ffeef5; }

.fm-conv-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.fm-conv-avatar-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--fm-primary-light), var(--fm-accent-light));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.fm-conv-details {
    flex: 1;
    min-width: 0;
}
.fm-conv-name {
    font-weight: 600;
    font-size: .95rem;
    display: flex;
    align-items: center;
    gap: 6px;
}
.fm-conv-preview {
    font-size: .85rem;
    color: var(--fm-mid);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fm-unread-badge {
    background: var(--fm-primary);
    color: white;
    font-size: .7rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.fm-msg-main { flex: 1; display: flex; flex-direction: column; }

.fm-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.fm-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fm-chat-bubble {
    max-width: 70%;
    padding: 10px 16px;
    border-radius: 18px;
    font-size: .95rem;
    line-height: 1.4;
    position: relative;
}
.fm-chat-bubble.fm-mine {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--fm-primary), var(--fm-primary-dark));
    color: var(--fm-white);
    border-bottom-right-radius: 4px;
}
.fm-chat-bubble.fm-theirs {
    align-self: flex-start;
    background: var(--fm-bg);
    color: var(--fm-dark);
    border-bottom-left-radius: 4px;
}

.fm-chat-time {
    font-size: .72rem;
    color: var(--fm-light);
    margin-top: 4px;
}
.fm-mine .fm-chat-time { color: rgba(255,255,255,.65); text-align: right; }
.fm-theirs .fm-chat-time { text-align: left; }

.fm-chat-input {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--fm-lighter);
}
.fm-chat-input textarea {
    flex: 1;
    resize: none;
    border: 2px solid var(--fm-lighter);
    border-radius: var(--fm-radius-sm);
    padding: 10px 14px;
    font-family: var(--fm-font);
    font-size: .95rem;
}
.fm-chat-input textarea:focus {
    outline: none;
    border-color: var(--fm-primary-light);
}

.fm-chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--fm-light);
    font-size: 1.1rem;
}

/* ─── Chemistry Test ───────────────────────────────────────────── */

.fm-chem-questions {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 28px;
}

.fm-chem-q {
    background: var(--fm-white);
    padding: 24px;
    border-radius: var(--fm-radius);
    box-shadow: var(--fm-card-shadow);
}
.fm-chem-q h4 {
    font-family: var(--fm-font-display);
    font-size: 1.15rem;
    margin-bottom: 14px;
}

.fm-chem-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}

.fm-chem-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border: 2px solid var(--fm-lighter);
    border-radius: var(--fm-radius-sm);
    cursor: pointer;
    transition: all var(--fm-transition);
    font-weight: 500;
}
.fm-chem-option:hover {
    border-color: var(--fm-primary-light);
    background: #ffeef5;
}
.fm-chem-option input:checked + span {
    color: var(--fm-primary);
}
.fm-chem-option:has(input:checked) {
    border-color: var(--fm-primary);
    background: #ffeef5;
}

.fm-chem-importance {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .88rem;
    color: var(--fm-mid);
}
.fm-chem-importance label { font-weight: 500; white-space: nowrap; }
.fm-chem-importance select {
    padding: 6px 10px;
    border: 1px solid var(--fm-lighter);
    border-radius: 6px;
    font-family: var(--fm-font);
    font-size: .85rem;
}

/* ─── Pagination ───────────────────────────────────────────────── */

.fm-pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 28px;
}
.fm-pagination button {
    padding: 8px 16px;
    border: 2px solid var(--fm-lighter);
    background: var(--fm-white);
    border-radius: var(--fm-radius-sm);
    cursor: pointer;
    font-family: var(--fm-font);
    font-weight: 600;
    transition: all var(--fm-transition);
}
.fm-pagination button:hover { border-color: var(--fm-primary-light); }
.fm-pagination button.active {
    background: var(--fm-primary);
    color: var(--fm-white);
    border-color: var(--fm-primary);
}

/* ─── Responsive ───────────────────────────────────────────────── */

/* Tablet (≤ 1024px) */
@media (max-width: 1024px) {
    .fm-wrap { padding: 24px 16px; }
    .fm-profile-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
    .fm-vp-main-photo { width: 260px; height: 340px; }
    .fm-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .fm-detail-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* Mobile (≤ 768px) */
@media (max-width: 768px) {
    .fm-wrap { padding: 16px 12px; }
    .fm-wrap h2 { font-size: 1.6rem; }
    .fm-wrap h3 { font-size: 1.15rem; }

    /* Dashboard */
    .fm-dash-header {
        flex-direction: column;
        text-align: center;
        padding: 20px;
        gap: 16px;
    }
    .fm-stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .fm-stat-card { padding: 16px 12px; }
    .fm-stat-num { font-size: 1.6rem; }
    .fm-stat-label { font-size: .78rem; }
    .fm-dash-actions { flex-direction: column; }
    .fm-dash-actions .fm-btn { width: 100%; justify-content: center; }
    .fm-welcome-banner { padding: 48px 20px; }
    .fm-welcome-banner h2 { font-size: 1.8rem; }

    /* Forms */
    .fm-row { flex-direction: column; gap: 0; }
    .fm-section { padding: 20px 16px; }
    .fm-field input, .fm-field select, .fm-field textarea {
        font-size: 16px; /* prevents iOS zoom on focus */
        padding: 12px 14px;
    }
    .fm-form-actions .fm-btn { width: 100%; }

    /* Browse / Profile Grid */
    .fm-profile-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
    .fm-card-photo { height: 200px; }
    .fm-card-info { padding: 10px 12px 8px; }
    .fm-card-info h4 { font-size: .95rem; }
    .fm-card-info p { font-size: .82rem; }
    .fm-card-compat { font-size: .72rem; padding: 3px 8px; }
    .fm-profile-card > .fm-btn { margin: 0 10px 10px; font-size: .82rem; padding: 6px 12px; }

    .fm-browse-header { flex-wrap: wrap; gap: 10px; }
    .fm-filter-row { flex-direction: column; gap: 10px; }
    .fm-filter-row .fm-field { min-width: 100%; }

    /* View Profile */
    .fm-vp-header { flex-direction: column; gap: 20px; }
    .fm-vp-main-photo { width: 100%; height: 300px; border-radius: var(--fm-radius); }
    .fm-vp-gallery { justify-content: flex-start; overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; padding-bottom: 4px; }
    .fm-vp-thumb { flex-shrink: 0; }
    .fm-vp-info h2 { font-size: 1.8rem; }
    .fm-vp-actions { flex-direction: column; }
    .fm-vp-actions .fm-btn { width: 100%; justify-content: center; }
    .fm-vp-body { max-width: 100%; }
    .fm-vp-section { padding: 16px; }
    .fm-detail-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

    /* Messages */
    .fm-messages-wrap {
        flex-direction: column;
        min-height: auto;
        border-radius: var(--fm-radius);
    }
    .fm-msg-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--fm-lighter);
        max-height: 280px;
        overflow-y: auto;
    }
    .fm-msg-sidebar h3 { padding: 14px 16px 8px; }
    .fm-conv-item { padding: 10px 16px; }
    .fm-chat-messages { max-height: 400px; padding: 14px; }
    .fm-chat-bubble { max-width: 85%; font-size: .9rem; }
    .fm-chat-input { padding: 12px; gap: 8px; }
    .fm-chat-input textarea {
        font-size: 16px; /* prevents iOS zoom */
        padding: 10px 12px;
    }
    .fm-chat-input .fm-btn { padding: 10px 16px; }

    /* Chemistry */
    .fm-chem-q { padding: 16px; }
    .fm-chem-q h4 { font-size: 1.05rem; }
    .fm-chem-option { padding: 10px 12px; }
    .fm-chem-importance { flex-direction: column; align-items: flex-start; gap: 6px; }
    .fm-chem-importance select { width: 100%; padding: 10px; font-size: 16px; }

    /* Buttons — bigger touch targets on mobile */
    .fm-btn { padding: 12px 24px; min-height: 44px; }
    .fm-btn-sm { padding: 10px 16px; min-height: 40px; }
    .fm-btn-lg { padding: 14px 28px; }

    /* Pagination */
    .fm-pagination { gap: 6px; }
    .fm-pagination button { padding: 10px 14px; min-height: 44px; min-width: 44px; }
}

/* Small phones (≤ 480px) */
@media (max-width: 480px) {
    .fm-wrap { padding: 12px 8px; }
    .fm-wrap h2 { font-size: 1.4rem; }

    .fm-profile-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .fm-card-photo { height: 240px; }

    .fm-stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .fm-stat-card { padding: 14px 8px; }
    .fm-stat-num { font-size: 1.4rem; }
    .fm-stat-icon { font-size: 1.4rem; }

    .fm-vp-main-photo { height: 250px; }
    .fm-vp-info h2 { font-size: 1.5rem; }
    .fm-compat-badge { padding: 6px 12px; }
    .fm-compat-score { font-size: 1.2rem; }

    .fm-detail-grid { grid-template-columns: 1fr 1fr; }
    .fm-tags { gap: 5px; }
    .fm-tag { font-size: .8rem; padding: 4px 10px; }

    .fm-conv-avatar, .fm-conv-avatar-placeholder { width: 40px; height: 40px; }
    .fm-conv-name { font-size: .9rem; }

    .fm-chat-bubble { max-width: 90%; }

    .fm-photo-frame { width: 140px; height: 180px; }
    .fm-main-photo { flex-direction: column; align-items: flex-start; }
    .fm-gallery-grid .fm-gallery-thumb { width: 80px; height: 80px; }
}

/* Safe area insets for notched phones */
@supports (padding: env(safe-area-inset-bottom)) {
    .fm-chat-input {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
}

