/* =============================================
   👥 멤버 선택 팝업 (member_selector) v2
   ============================================= */

/* 오버레이 */
.ms-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.55);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}
.ms-overlay.open { display: flex; }

/* 패널 */
.ms-panel {
    width: 92%;
    max-width: 400px;
    max-height: 80vh;
    background: #fff;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    animation: msPopIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
@keyframes msPopIn {
    from { transform: scale(0.85); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

/* 헤더 */
.ms-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid #f0f0f0;
}
.ms-header-left { flex: 1; }
.ms-title {
    font-size: 19px;
    font-weight: 800;
    color: #5A5248;
    line-height: 1.3;
}
.ms-desc {
    font-size: 13px;
    color: #999;
    margin-top: 4px;
    line-height: 1.4;
}
.ms-close {
    width: 32px; height: 32px;
    border: none; background: #f0f0f0;
    border-radius: 8px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; color: #999;
    flex-shrink: 0;
    margin-top: 2px;
}
.ms-close:active { background: #e0e0e0; }

/* 히어로 */
.ms-hero {
    text-align: center;
    padding: 24px 16px 20px;
}
.ms-hero-icon {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px; /* emoji 폴백 */
}
.ms-hero-text {
    font-size: 14px;
    color: #999;
    line-height: 1.6;
}

/* 멤버 목록 영역 */
.ms-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px 20px;
    -webkit-overflow-scrolling: touch;
}

/* 멤버 카드 */
.ms-member-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border: 2px solid #eee;
    border-radius: 14px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.15s;
    background: #fff;
    position: relative;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.ms-member-card:active { transform: scale(0.98); background: #f8f8f8; }
.ms-member-card.selected { border: 2px solid #9B9080; background: #f8f8f8; }

/* 아바타 */
.ms-avatar {
    width: 48px; height: 48px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.ms-avatar.male   { background: #E8F0FE; }
.ms-avatar.female { background: #FDE8EF; }

/* 멤버 정보 */
.ms-member-info { flex: 1; min-width: 0; }
.ms-member-name {
    font-size: 16px; font-weight: 700; color: #5A5248;
    margin-bottom: 3px;
    display: flex; align-items: center; gap: 6px;
}
.ms-member-name-text {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    min-width: 0;
}
.ms-completed-badge {
    flex-shrink: 0;
    font-size: 10px; font-weight: 700;
    color: #fff; background: #5A9BB5;
    padding: 2px 6px; border-radius: 4px;
    white-space: nowrap;
}
.ms-member-detail { font-size: 12px; color: #999; line-height: 1.4; }
.ms-member-relation {
    display: inline-block;
    font-size: 11px; font-weight: 600;
    color: #5A9BB5;
    background: rgba(90,155,181,0.1);
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 4px;
}

/* 편집/삭제 아이콘 */
.ms-card-actions { display: flex; gap: 6px; flex-shrink: 0; }
.ms-card-btn {
    width: 30px; height: 30px;
    border: none; background: #f0f0f0;
    border-radius: 6px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.ms-card-btn:active { background: #e0e0e0; }
.ms-card-btn svg { width: 14px; height: 14px; stroke: #888; fill: none; stroke-width: 2; }

/* 궁합 dual 선택 배지 */
.ms-sel-badge {
    position: absolute;
    top: -6px; right: 12px;
    font-size: 11px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 10px;
    color: #fff;
    z-index: 1;
}
.ms-sel-first { background: #9B9080; }
.ms-sel-second { background: #7AB0C7; }

.ms-dual-hint {
    text-align: center;
    padding: 12px;
    font-size: 13px;
    color: #999;
    margin-top: 4px;
}

/* 새 멤버 추가 버튼 */
.ms-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 16px;
    border: 2px dashed #d0d0d0;
    border-radius: 14px;
    background: #fafafa;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    color: #666;
    transition: all 0.2s;
    margin-bottom: 14px;
}
.ms-add-btn:active { background: #f0f0f0; border-color: #bbb; color: #444; }

.ms-empty {
    text-align: center;
    padding: 20px 20px 10px;
    color: #bbb;
    font-size: 14px;
    line-height: 1.6;
}

/* =============================================
   Step 2: 확인 + 추가 입력
   ============================================= */

/* 뒤로가기 */
.ms-s2-back {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 600;
    color: #888;
    cursor: pointer;
    padding: 4px 0 16px;
    transition: color 0.15s;
}
.ms-s2-back:active { color: #555; }
.ms-s2-back svg { flex-shrink: 0; }

/* 선택된 멤버 요약 카드 */
.ms-s2-member {
    background: #f8f9fa;
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 10px;
}
.ms-s2-role {
    font-size: 11px;
    font-weight: 800;
    color: #5A5248;
    background: #E8E8E8;
    display: inline-block;
    padding: 2px 10px;
    border-radius: 6px;
    margin-bottom: 8px;
}
.ms-s2-member-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.ms-s2-member-info { flex: 1; min-width: 0; }

/* 구분선 */
.ms-s2-divider {
    height: 1px;
    background: #eee;
    margin: 16px 0;
}

/* 추가 입력 그룹 */
.ms-extra-group {
    margin-bottom: 20px;
}
.ms-extra-label {
    font-size: 14px;
    font-weight: 700;
    color: #5A5248;
    margin-bottom: 10px;
}

/* 그리드 선택 버튼 */
.ms-extra-grid {
    display: grid;
    gap: 8px;
}
.ms-egrid-btn {
    padding: 12px 6px;
    border: 2px solid #E8E8E8;
    border-radius: 10px;
    background: #F4F5F7;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.ms-egrid-btn:active { background: #eee; }
.ms-egrid-btn.active {
    border: 2px solid #9B9080;
    background: #9B9080;
}
.ms-egrid-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}
.ms-egrid-btn .ms-egrid-icon svg { stroke: #555; fill: none; stroke-width: 1.5; width: 20px; height: 20px; }
.ms-egrid-btn.active .ms-egrid-icon svg { stroke: #fff; }
.ms-egrid-label {
    font-size: 13px;
    font-weight: 700;
    color: #555;
}
.ms-egrid-btn.active .ms-egrid-label { color: #fff; }

/* 분석 시작 버튼 */
.ms-start-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    background: #9B9080;
    color: #fff;
    margin-top: 10px;
}
.ms-start-btn:disabled {
    background: #e0e0e0;
    color: #aaa;
    cursor: default;
}
.ms-start-btn:not(:disabled):active {
    transform: scale(0.98);
    opacity: 0.9;
}

/* ── 조건부 영역 (배우자/주말 선택) ── */
.ms-cond-section { margin-top: 16px; }
.ms-cond-label {
    font-size: 13px; font-weight: 700; color: #5A5248;
    margin-bottom: 8px;
}
.ms-cond-btns { display: flex; gap: 8px; }
.ms-cond-btn {
    flex: 1; padding: 12px;
    border: 2px solid #e0e0e0; border-radius: 10px;
    background: #fff; color: #777;
    font-size: 14px; font-weight: 600;
    cursor: pointer; text-align: center;
    transition: all 0.15s;
}
.ms-cond-btn.active { border-color: #9B9080; background: #F5F0EA; color: #5A5248; }
.ms-cond-spouse { margin-top: 12px; }
.ms-cond-spouse-btn {
    width: 100%; padding: 14px;
    border: 2px dashed #d0d0d0; border-radius: 10px;
    background: #fafafa; cursor: pointer;
    font-size: 14px; font-weight: 700; color: #888;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    transition: all 0.15s;
}
.ms-cond-spouse-btn:active { background: #f0f0f0; }
.ms-cond-spouse-card {
    padding: 12px 16px;
    background: #F5F0EA; border: 1px solid #E0D8CE;
    border-radius: 10px;
    display: flex; align-items: center; gap: 12px;
}
.ms-cond-change {
    margin-left: auto; padding: 6px 12px;
    border: 1px solid #ccc; border-radius: 6px;
    background: #fff; color: #888;
    font-size: 12px; font-weight: 600; cursor: pointer;
}
.ms-cond-spouse-list {
    border: 1px solid #eee; border-radius: 10px;
    overflow: hidden; max-height: 200px; overflow-y: auto;
}
.ms-cond-spouse-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    display: flex; justify-content: space-between; align-items: center;
    transition: background 0.1s;
}
.ms-cond-spouse-item:active { background: #f8f8f8; }
.ms-cond-spouse-item:last-child { border-bottom: none; }

/* =============================================
   미니 캘린더 (택일용)
   ============================================= */
.ms-cal-wrap {
    background: #F8F9FA;
    border: 1px solid #E8E8E8;
    border-radius: 14px;
    overflow: hidden;
}
.ms-cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 12px 10px;
}
.ms-cal-nav {
    background: none;
    border: none;
    font-size: 13px;
    color: #666;
    cursor: pointer;
    padding: 8px 14px;
    border-radius: 8px;
    transition: background 0.15s;
}
.ms-cal-nav:active { background: #eee; }
.ms-cal-nav:disabled { color: #ddd; cursor: default; }
.ms-cal-nav:disabled:active { background: none; }
.ms-cal-title {
    font-size: 16px;
    font-weight: 800;
    color: #5A5248;
    letter-spacing: 1px;
}
.ms-cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    padding: 0 8px 8px;
    font-size: 12px;
    font-weight: 600;
    color: #999;
}
.ms-cal-weekdays span:first-child { color: #E57373; }
.ms-cal-weekdays span:last-child { color: #64B5F6; }
.ms-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    padding: 0 8px 10px;
}
.ms-cal-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    transition: all 0.15s;
    border: 2px solid transparent;
    -webkit-tap-highlight-color: transparent;
}
.ms-cal-day:active:not(.disabled):not(.empty) { background: #eee; }
.ms-cal-day.today { border-color: #ccc; }
.ms-cal-day.selected { background: #9B9080; color: #fff !important; border-color: #9B9080; }
.ms-cal-day.disabled { color: #ddd; cursor: default; }
.ms-cal-day.disabled.sunday { color: #F5CECE; }
.ms-cal-day.disabled.saturday { color: #C5DCEF; }
.ms-cal-day.empty { cursor: default; }
.ms-cal-day.sunday { color: #E57373; }
.ms-cal-day.saturday { color: #64B5F6; }

/* =============================================
   멤버 추가/수정 폼
   ============================================= */
.ms-form { padding: 0 16px 20px; }

.ms-form-group { margin-bottom: 20px; }
.ms-form-label {
    display: flex; align-items: center; gap: 8px;
    font-size: 14px; font-weight: 700; color: #5A5248;
    margin-bottom: 8px;
}
.ms-form-badge {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: #5A5248; color: #fff;
    font-size: 11px; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.ms-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px; color: #333;
    background: #fff; outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}
.ms-input:focus { border-color: #9B9080; }
.ms-input::placeholder { color: #ccc; }

.ms-btn-group { display: flex; gap: 8px; }
.ms-opt-btn {
    flex: 1; padding: 13px 0;
    border: 2px solid #e0e0e0; border-radius: 10px;
    background: #fff; color: #777;
    font-size: 15px; font-weight: 600;
    cursor: pointer; text-align: center;
    transition: all 0.15s;
}
.ms-opt-btn.active { background: #9B9080; color: #fff; border-color: #9B9080; }

.ms-siju-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ms-siju-btn {
    padding: 12px 4px;
    border: 2px solid #E8E8E8; border-radius: 10px;
    background: #F4F5F7; cursor: pointer;
    text-align: center;
    font-size: 14px; font-weight: 700; color: #333;
    transition: all 0.15s;
}
.ms-siju-btn span { display: block; font-size: 10px; font-weight: 400; color: #aaa; margin-top: 2px; }
.ms-siju-btn.active { border: 2px solid #9B9080; background: #9B9080; color: #fff; }
.ms-siju-btn.active span { color: rgba(255,255,255,0.7); }

.ms-time-seg {
    display: flex; background: #EDEEF0;
    border-radius: 10px; padding: 3px; gap: 2px;
    margin-bottom: 12px;
}
.ms-seg-btn {
    flex: 1; padding: 10px 0;
    border: none; border-radius: 8px;
    font-size: 13px; font-weight: 500;
    color: #888; background: transparent;
    cursor: pointer; transition: all 0.2s;
}
.ms-seg-btn.active { font-weight: 700; color: #fff; background: #9B9080; }

.ms-city-btn {
    padding: 14px 16px;
    border: 1px solid #e0e0e0; border-radius: 10px;
    background: #F4F5F7; cursor: pointer;
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; box-sizing: border-box;
}
.ms-city-btn .city-name { font-size: 15px; font-weight: 600; color: #333; }
.ms-city-btn .city-arrow { font-size: 12px; color: #999; }

.ms-relation-group { display: flex; flex-wrap: wrap; gap: 8px; }
.ms-relation-btn {
    padding: 10px 16px;
    border: 1px solid #e0e0e0; border-radius: 8px;
    background: #fff; color: #777;
    font-size: 13px; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
}
.ms-relation-btn.active { background: #9B9080; color: #fff; border-color: #9B9080; }

.ms-submit-btn {
    width: 100%; padding: 16px;
    border: none; border-radius: 12px;
    font-size: 16px; font-weight: 800;
    cursor: pointer; transition: all 0.2s;
    background: #9B9080; color: #fff;
    margin-top: 10px;
}
.ms-submit-btn:disabled { background: #e0e0e0; color: #aaa; cursor: default; }
.ms-back-link {
    display: block; text-align: center;
    padding: 12px; font-size: 14px;
    color: #999; cursor: pointer; margin-top: 4px;
}

/* 도시 검색 모달 */
.ms-city-modal {
    display: none; position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.45); z-index: 10001;
    justify-content: center; align-items: flex-start;
}
.ms-city-modal.open { display: flex; }
.ms-city-inner {
    width: 100%; max-width: 430px; height: 100%;
    background: #fff; display: flex; flex-direction: column;
}
.ms-city-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid #eee;
}
.ms-city-header-title { font-size: 17px; font-weight: 800; color: #5A5248; }
.ms-city-close { font-size: 24px; color: #999; cursor: pointer; background: none; border: none; }
.ms-city-search {
    width: calc(100% - 32px);
    padding: 12px 16px;
    border: 1px solid #e0e0e0; border-radius: 10px;
    font-size: 15px; box-sizing: border-box;
    outline: none; margin: 12px 16px;
}
.ms-city-hint {
    text-align: center; padding: 20px;
    color: #aaa; font-size: 13px; line-height: 1.7;
}
.ms-city-list { flex: 1; overflow-y: auto; padding: 0 16px 20px; }
.ms-city-item {
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0; cursor: pointer;
    font-size: 15px; color: #333;
    display: flex; justify-content: space-between; align-items: center;
}
.ms-city-item:active { background: #f8f8f8; }

/* 삭제 확인 */
.ms-confirm-overlay {
    display: none; position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 10002;
    align-items: center; justify-content: center;
}
.ms-confirm-overlay.open { display: flex; }
.ms-confirm-box {
    background: #fff; width: 85%; max-width: 320px;
    border-radius: 16px; padding: 24px 20px; text-align: center;
}
.ms-confirm-title { font-size: 17px; font-weight: 800; color: #5A5248; margin-bottom: 8px; }
.ms-confirm-msg { font-size: 14px; color: #666; margin-bottom: 20px; line-height: 1.5; }
.ms-confirm-btns { display: flex; gap: 8px; }
.ms-confirm-btns button {
    flex: 1; padding: 13px; border-radius: 10px;
    font-size: 15px; font-weight: 700; cursor: pointer; border: none;
}
.ms-confirm-cancel { background: #f0f0f0; color: #666; }
.ms-confirm-ok { background: #e74c3c; color: #fff; }
