/* ============================================================
   뉴명(NewMyoung) Design System
   - Pencil 디자인 기반 CSS 토큰
   - Font: Pretendard(한글), Outfit(영문/숫자)
   ============================================================ */

/* ---------- Design Tokens ---------- */
:root {
    /* Brand */
    --nm-primary: #3D8A5A;
    --nm-primary-light: #C8F0D8;

    /* Background & Surface */
    --nm-bg: #F5F4F1;
    --nm-surface: #FFFFFF;
    --nm-surface-muted: #EDECEA;

    /* Border */
    --nm-border: #E5E4E1;
    --nm-border-strong: #D1D0CD;

    /* Text */
    --nm-text-primary: #1A1918;
    --nm-text-secondary: #6D6C6A;
    --nm-text-tertiary: #9C9B99;

    /* Accent & Status */
    --nm-accent: #D89575;
    --nm-accent-dark: #D08068;
    --nm-warning: #D4A64A;
    --nm-community: #7C3AED;
    --nm-community-light: #F3EEFF;

    /* Ohang (오행) */
    --nm-oh-wood: #2E8B57;
    --nm-oh-wood-light: #E8F5EC;
    --nm-oh-fire: #DC4545;
    --nm-oh-fire-light: #FDE8E8;
    --nm-oh-earth: #D4A017;
    --nm-oh-earth-light: #FFF8E1;
    --nm-oh-metal: #8C8C8C;
    --nm-oh-metal-light: #F5F5F5;
    --nm-oh-water: #2563EB;
    --nm-oh-water-light: #EFF6FF;

    /* Yin-Yang */
    --nm-yang: #DC4545;
    --nm-yang-light: #FDE8E8;
    --nm-yin: #2563EB;
    --nm-yin-light: #EFF6FF;

    /* Grade Colors */
    --nm-grade-s: #3D8A5A;
    --nm-grade-s-bg: #C8F0D8;
    --nm-grade-a: #2563EB;
    --nm-grade-a-bg: #EFF6FF;
    --nm-grade-b: #8C8C8C;
    --nm-grade-b-bg: #F5F5F5;

    /* Spacing */
    --nm-safe-bottom: env(safe-area-inset-bottom, 0px);
    --nm-nav-height: 52px;
}

/* ---------- Font ---------- */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css');

/* ---------- Base ---------- */
.nm-app {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--nm-bg);
    font-family: 'Pretendard', -apple-system, sans-serif;
    color: var(--nm-text-primary);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ---------- Common Nav Bar ---------- */
.nm-navbar {
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--nm-nav-height);
    padding: 0 16px;
}
.nm-navbar-back {
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; background: none; border: none; padding: 0;
    color: var(--nm-text-primary); font-size: 20px;
}
.nm-navbar-title {
    font-family: 'Pretendard';
    font-size: 18px; font-weight: 600;
    color: var(--nm-text-primary);
}
.nm-navbar-spacer { flex: 1; }
.nm-navbar-icon {
    width: 22px; height: 22px;
    color: var(--nm-text-secondary); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
}

/* ---------- Step Indicator (bar type) ---------- */
.nm-step-bar {
    display: flex;
    gap: 4px;
    padding: 0 24px;
    height: 4px;
}
.nm-step-bar > div {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--nm-border);
}
.nm-step-bar > div.active { background: var(--nm-primary); }

/* ---------- Card ---------- */
.nm-card {
    background: var(--nm-surface);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(26,25,24,0.03);
}

/* ---------- Button ---------- */
.nm-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 16px;
    font-family: 'Pretendard';
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    height: 56px;
    width: 100%;
    transition: opacity 0.2s;
}
.nm-btn:active { opacity: 0.85; }
.nm-btn-primary { background: var(--nm-primary); color: #FFFFFF; }
.nm-btn-outline {
    background: var(--nm-surface);
    color: var(--nm-text-primary);
    border: 1px solid var(--nm-border);
}
.nm-btn-ghost {
    background: transparent;
    color: var(--nm-text-tertiary);
    font-weight: 500; font-size: 14px;
    height: 44px;
}
.nm-btn-sm {
    height: 48px; font-size: 14px; font-weight: 500;
    border-radius: 12px;
}

/* ---------- Input ---------- */
.nm-input {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    border: 1px solid var(--nm-border);
    border-radius: 12px;
    font-family: 'Pretendard';
    font-size: 15px;
    color: var(--nm-text-primary);
    background: var(--nm-surface);
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
}
.nm-input:focus { border-color: var(--nm-primary); }
.nm-input::placeholder { color: var(--nm-text-tertiary); }

/* ---------- Form ---------- */
.nm-field { margin-bottom: 0; }
.nm-field-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--nm-text-primary);
    margin-bottom: 8px;
}
.nm-field-hint {
    font-size: 12px;
    color: var(--nm-text-tertiary);
    margin-top: 6px;
}

/* ---------- Gender Buttons ---------- */
.nm-gender-group { display: flex; gap: 12px; }
.nm-gender-btn {
    flex: 1; height: 48px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 12px; font-size: 15px; font-weight: 600;
    cursor: pointer; transition: all 0.2s;
    background: var(--nm-surface);
    border: 1px solid var(--nm-border);
    color: var(--nm-text-secondary);
}
.nm-gender-btn.selected {
    border-color: var(--nm-primary);
    background: var(--nm-primary-light);
    color: var(--nm-primary);
}

/* ---------- Grade Badge ---------- */
.nm-grade-badge {
    display: inline-flex;
    align-items: center; justify-content: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px; font-weight: 700;
}
.nm-grade-badge.s { background: var(--nm-grade-s-bg); color: var(--nm-grade-s); }
.nm-grade-badge.a { background: var(--nm-grade-a-bg); color: var(--nm-grade-a); }
.nm-grade-badge.b { background: var(--nm-grade-b-bg); color: var(--nm-grade-b); }

/* ---------- Premium Badge ---------- */
.nm-premium-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 8px;
    background: #FFF3E0;
    font-size: 11px;
    font-weight: 600;
    color: var(--nm-warning);
}

/* ---------- Ohang Badge ---------- */
.nm-ohang-badge {
    display: inline-flex;
    align-items: center; justify-content: center;
    min-width: 28px; height: 28px;
    border-radius: 6px; padding: 0 6px;
    font-size: 12px; font-weight: 600; color: white;
}
.nm-ohang-badge.wood { background: var(--nm-oh-wood); }
.nm-ohang-badge.fire { background: var(--nm-oh-fire); }
.nm-ohang-badge.earth { background: var(--nm-oh-earth); }
.nm-ohang-badge.metal { background: var(--nm-oh-metal); }
.nm-ohang-badge.water { background: var(--nm-oh-water); }

/* ---------- Menu Card (Home) ---------- */
.nm-menu-card {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 72px;
    padding: 0 20px;
    background: var(--nm-surface);
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(26,25,24,0.03);
    cursor: pointer;
    transition: transform 0.15s;
}
.nm-menu-card:active { transform: scale(0.98); }
.nm-menu-icon {
    width: 44px; height: 44px;
    border-radius: 100px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
}
.nm-menu-text { flex: 1; }
.nm-menu-text h3 {
    font-size: 15px; font-weight: 600;
    color: var(--nm-text-primary); margin: 0 0 2px;
}
.nm-menu-text p {
    font-size: 12px; color: var(--nm-text-tertiary); margin: 0;
}
.nm-menu-arrow {
    color: var(--nm-text-tertiary); font-size: 14px;
}

/* ---------- Name Card (03) ---------- */
.nm-name-card {
    background: var(--nm-surface);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(26,25,24,0.03);
    cursor: pointer;
}
.nm-name-card.selected {
    outline: 2px solid var(--nm-primary);
    background: #F0FFF5;
}

/* ---------- Hanja Card (04) ---------- */
.nm-hanja-card {
    background: var(--nm-surface);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 2px 12px rgba(26,25,24,0.03);
}

/* ---------- Score Circle ---------- */
.nm-score-circle {
    width: 120px; height: 120px;
    border-radius: 60px;
    background: var(--nm-primary-light);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
}
.nm-score-circle .score-num {
    font-family: 'Outfit', sans-serif;
    font-size: 36px; font-weight: 700;
    color: var(--nm-primary);
}
.nm-score-circle .score-label {
    font-family: 'Outfit', sans-serif;
    font-size: 13px; color: var(--nm-primary);
}

/* ---------- Analysis Card ---------- */
.nm-analysis-card {
    background: var(--nm-surface);
    border-radius: 16px;
    padding: 20px;
}

/* ---------- Bottom Area ---------- */
.nm-bottom-area {
    padding: 16px 24px 40px;
}

/* ---------- Toggle ---------- */
.nm-toggle {
    width: 44px; height: 24px;
    border-radius: 12px;
    background: var(--nm-border);
    position: relative; cursor: pointer;
    transition: background 0.2s;
}
.nm-toggle::after {
    content: '';
    width: 20px; height: 20px;
    border-radius: 50%;
    background: white;
    position: absolute;
    top: 2px; left: 2px;
    transition: transform 0.2s;
}
.nm-toggle.on { background: #4CAF50; }
.nm-toggle.on::after { transform: translateX(20px); }

/* ---------- Page Layout Fix ---------- */
/* container: 절대높이 고정, content: 꽉 채움(스크롤X), 페이지 내부에서 스크롤 관리 */
.sub-page-container {
    overflow: hidden;
}
.sub-page-content {
    position: absolute !important;
    top: 0; left: 0; right: 0; bottom: 0;
    overflow: hidden !important;
    padding: 0 !important;
}
/* 페이지 root: 전체 높이 flex column */
.sub-page-content > div {
    height: 100%;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden;
}
/* 헤더: 고정 (스크롤 X) */
.nm-navbar { flex-shrink: 0; }
.nm-step-bar { flex-shrink: 0; }
/* 스크롤 영역 */
.nm-scroll-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}
/* 바닥 고정 */
.nm-bottom-fixed {
    flex-shrink: 0;
}

/* ---------- Utilities ---------- */
.nm-flex { display: flex; }
.nm-flex-col { display: flex; flex-direction: column; }
.nm-flex-center { display: flex; align-items: center; justify-content: center; }
.nm-flex-between { display: flex; align-items: center; justify-content: space-between; }
.nm-gap-4 { gap: 4px; }
.nm-gap-8 { gap: 8px; }
.nm-gap-12 { gap: 12px; }
.nm-gap-16 { gap: 16px; }
.nm-gap-24 { gap: 24px; }
.nm-text-center { text-align: center; }
.nm-hide { display: none !important; }
.nm-font-en { font-family: 'Outfit', sans-serif; }
