:root {
    /* 새로운 프리미엄 컬러 팔레트 (Standalone 디자인 참고) */
    --primary: #3F5A40; 
    --primary-light: #5C7D5D;
    --primary-dark: #263827;
    --accent: #B5754C; 
    --accent-light: #D18D60;
    --bg-color: #FDFBF7; /* 밝은 배경으로 변경 */
    --bg-alt: #F0F4ED; /* 밝은 배경으로 변경 */
    --card-bg: rgba(255, 255, 255, 0.95);
    --text-main: #2C332C;
    --text-muted: #6B726C;
    --border: rgba(63, 90, 64, 0.1);
    
    /* 상태 컬러 */
    --completed: #3F5A40;
    --missed: #B5754C; 
    --future: rgba(63, 90, 64, 0.08);
    
    /* 타이포그래피 */
    --font-sans: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-serif: 'Nanum Myeongjo', Georgia, serif;
    
    /* 쉐도우 */
    --shadow-sm: 0 4px 12px rgba(63, 90, 64, 0.06);
    --shadow-md: 0 12px 30px rgba(63, 90, 64, 0.1);
    --shadow-lg: 0 24px 50px rgba(63, 90, 64, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body { 
    background-color: #D6D2C9; /* PC에서 보이는 배경 */
    display: flex; 
    justify-content: center; 
    height: 100vh;
    height: 100dvh; /* 모바일 브라우저 하단바 고려 */
    overflow: hidden; 
    font-family: var(--font-sans);
    color: var(--text-main);
}

/* 모바일 웹앱 컨테이너 */
#app-container {
    width: 100%; 
    max-width: 480px; 
    height: 100%; 
    background-color: var(--bg-color);
    position: relative; 
    overflow-y: auto; 
    overflow-x: hidden;
    box-shadow: 0 0 40px rgba(0,0,0,0.1);
}

.screen {
    display: none; 
    width: 100%; 
    min-height: 100%; 
    padding: 40px 24px 80px 24px; /* 하단 여백 대폭 추가 */
    flex-direction: column; 
    animation: fadeScaleIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.screen.active { display: flex; }

@keyframes fadeScaleIn { 
    from { opacity: 0; transform: translateY(10px) scale(0.98); } 
    to { opacity: 1; transform: translateY(0) scale(1); } 
}

/* 타이포그래피 */
h1, h2, h3 { 
    font-family: var(--font-serif);
    color: var(--primary-dark);
    line-height: 1.3;
}

h1 { font-size: 28px; font-weight: 800; margin-bottom: 8px; }
h2 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
h3 { font-size: 20px; font-weight: 700; }

.subtitle { 
    color: var(--text-muted); 
    font-size: 15px; 
    line-height: 1.5;
    margin-bottom: 24px; 
}

/* 글래스모피즘 카드 공통 */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 20px;
    box-shadow: var(--shadow-md);
}

/* --- 등록 화면 (브랜드 디자인 적용) --- */
.brand-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 20px 0 40px;
}

.brand-circle {
    width: 140px;
    height: 140px;
    background-color: var(--bg-alt);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    box-shadow: inset 0 0 0 3px rgba(63, 90, 64, 0.1);
    position: relative;
}

.brand-circle::after {
    content: '';
    position: absolute;
    top: -10px; left: -10px; right: -10px; bottom: -10px;
    border: 1.5px dashed var(--primary-light);
    border-radius: 50%;
    opacity: 0.3;
    animation: rotate 20s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.brand-number {
    font-family: var(--font-serif);
    font-size: 52px;
    font-style: italic;
    color: var(--primary);
    font-weight: 700;
    padding-right: 8px; /* 이탤릭체 및 폰트 특성으로 인한 시각적 우측 치우침 보정 */
}

.brand-subtitle {
    font-size: 14px;
    letter-spacing: 5px;
    color: var(--accent);
    font-weight: 500;
    text-align: center;
    padding-left: 5px; /* 시각적 중앙 정렬을 위해 글자간격 보정 */
}

.welcome-text { margin-bottom: 30px; text-align: center; }

#register-form { padding: 32px 24px; }

/* 폼 디자인 */
.form-group { margin-bottom: 24px; }
.form-group label, .form-group .form-label { 
    display: block; 
    font-size: 13px; 
    font-weight: 600; 
    color: var(--primary); 
    margin-bottom: 10px; 
    letter-spacing: -0.3px;
}

input[type="text"] { 
    width: 100%; 
    padding: 16px; 
    border: 1px solid var(--border); 
    border-radius: 14px; 
    font-size: 16px; 
    outline: none; 
    transition: all 0.3s ease; 
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-main);
}

input[type="text"]:focus { 
    border-color: var(--primary); 
    box-shadow: 0 0 0 4px rgba(63, 90, 64, 0.1); 
    background: white;
}

input[type="text"]::placeholder { color: #A0A5A0; }

/* 세그먼트 버튼 (교인/방문자) */
.segmented-control {
    display: flex;
    background: var(--future);
    border-radius: 14px;
    padding: 6px;
    margin-top: 8px;
}
.segment-btn {
    flex: 1;
    text-align: center;
    position: relative;
    cursor: pointer;
}
.segment-btn input { display: none; }
.segment-btn span {
    display: block;
    padding: 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: 10px;
    transition: all 0.2s ease;
}
.segment-btn input:checked + span {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}

/* 부서 버튼 */
.department-group {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}
.dept-btn {
    flex: 1;
    cursor: pointer;
}
.dept-btn input { display: none; }
.dept-btn .btn-custom {
    display: block;
    text-align: center;
    padding: 14px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--future);
    border-radius: 12px;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}
.dept-btn input:checked + .btn-custom {
    background: white;
    color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(63, 90, 64, 0.1);
}

/* 버튼 디자인 */
button { 
    border: none; 
    border-radius: 14px; 
    font-size: 16px; 
    font-weight: 600; 
    cursor: pointer; 
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1); 
    display: flex;
    align-items: center;
    justify-content: center;
}
button:active { transform: scale(0.97); }

.primary-btn { 
    width: 100%; 
    padding: 18px; 
    background-color: var(--primary); 
    color: white; 
    box-shadow: 0 8px 20px rgba(63, 90, 64, 0.25); 
}
.primary-btn:hover { background-color: var(--primary-dark); }

.secondary-btn { 
    width: 100%; 
    padding: 18px; 
    background-color: transparent; 
    color: var(--primary); 
    border: 1px solid var(--primary); 
}
.secondary-btn:hover { background-color: rgba(63, 90, 64, 0.05); }

/* --- 메인 홈 화면 --- */
header { margin-bottom: 30px; }
#user-greeting { font-size: 16px; color: var(--accent); font-weight: 500; display: block; margin-bottom: 8px;}

.header-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    margin-top: 24px;
}
.stat-box { display: flex; flex-direction: column; }
.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; margin-bottom: 6px; }
.stat-value-container { display: flex; align-items: baseline; gap: 4px; }
.stat-value { font-size: 32px; font-family: var(--font-serif); font-weight: 800; color: var(--primary); }
.stat-total { font-size: 16px; color: var(--text-muted); font-weight: 500; }
.stat-icon { font-size: 32px; opacity: 0.8; }

/* 나무 UI */
.tree-container { 
    padding: 30px 24px; 
    text-align: center; 
    margin-bottom: 30px; 
}

/* 주간 참여 그래프 */
.bar-chart {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    height: 100px;
}
.bar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    gap: 8px;
}
.bar-track {
    width: 20px;
    height: 70px;
    background: var(--future);
    border-radius: 10px;
    display: flex;
    align-items: flex-end;
    position: relative;
}
.bar-fill {
    width: 100%;
    background: var(--primary);
    border-radius: 10px;
    transition: height 1s cubic-bezier(0.16, 1, 0.3, 1);
}
.bar-fill.today {
    background: var(--accent);
}
.bar-fill.future {
    background: transparent;
}
.bar-value {
    position: absolute;
    top: -22px;
    width: 100%;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
}
.bar-value.today { color: var(--accent); }
.bar-value.future { color: #A0A5A0; }

.bar-label {
    font-size: 12px;
    color: var(--text-muted);
}
.bar-item.today .bar-label {
    font-weight: 700;
    color: var(--accent);
}
.tree-header { margin-bottom: 24px; display: flex; flex-direction: column; align-items: center;}
.tree-stage-text { 
    font-size: 14px; 
    font-weight: 600; 
    color: var(--primary); 
    padding: 6px 16px; 
    background: var(--bg-alt); 
    border-radius: 20px; 
    margin-bottom: 16px;
    letter-spacing: -0.3px;
}

.tree-progress { width: 100%; }
.progress-bar-bg { 
    width: 100%; height: 8px; 
    background-color: var(--future); 
    border-radius: 10px; overflow: hidden; 
}
.progress-bar-fill { 
    height: 100%; 
    background-color: var(--primary); 
    width: 0%; 
    border-radius: 10px;
    transition: width 1.2s cubic-bezier(0.16, 1, 0.3, 1); 
}

.tree-image-wrapper { 
    width: 240px; height: 240px; 
    margin: 0 auto; 
    position: relative; 
    display: flex; align-items: center; justify-content: center;
}
.tree-circle-bg {
    position: absolute;
    width: 100%; height: 100%;
    background: var(--bg-alt);
    border-radius: 50%;
    z-index: 0;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.03);
}
#tree-video,
#tree-image { 
    width: 85%; height: 85%; 
    z-index: 1;
    position: relative;
    transition: opacity 0.5s, transform 0.5s; 
}
#tree-image {
    object-fit: contain; 
}
#tree-video {
    object-fit: cover;
    border-radius: 50%; /* 네모난 영상을 동그랗게 보이게 함 */
}

.tree-message { 
    margin-top: 24px; 
    font-size: 15px; 
    color: var(--text-main); 
    line-height: 1.6;
}

.actions { display: flex; flex-direction: column; gap: 12px; }

/* 맥박 애니메이션 (오늘 기도 강조) */
.pulse-anim { animation: pulse 2s infinite; }
@keyframes pulse { 
    0% { box-shadow: 0 0 0 0 rgba(63, 90, 64, 0.4); } 
    70% { box-shadow: 0 0 0 15px rgba(63, 90, 64, 0); } 
    100% { box-shadow: 0 0 0 0 rgba(63, 90, 64, 0); } 
}

/* --- 달력 모달 --- */
.modal { 
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    z-index: 1000; align-items: flex-end; justify-content: center;
}
.modal.show { display: flex; }
.modal-backdrop {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(44, 51, 44, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0; transition: opacity 0.3s;
}
.modal.show .modal-backdrop { opacity: 1; }

.modal-content { 
    position: relative;
    background: var(--bg-color); 
    width: 100%; max-width: 480px; 
    height: 85vh; 
    border-radius: 28px 28px 0 0; 
    padding: 30px 24px; 
    display: flex; flex-direction: column; 
    box-shadow: 0 -10px 40px rgba(0,0,0,0.15);
    transform: translateY(100%); transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal.show .modal-content { transform: translateY(0); }

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.close-btn { 
    background: var(--bg-alt); 
    border-radius: 50%;
    width: 36px; height: 36px; 
    font-size: 24px; color: var(--primary); 
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
}

.modal-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.calendar-desc { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; line-height: 1.5; }

.calendar-legend { display: flex; gap: 16px; margin-bottom: 20px; font-size: 13px; font-weight: 500; color: var(--text-main); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.color-box { width: 12px; height: 12px; border-radius: 3px; }
.completed-box { background: var(--completed); }
.missed-box { background: var(--bg-color); border: 2px solid var(--missed); }
.today-box { background: var(--bg-color); border: 2px solid var(--primary); }

.calendar-grid { 
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; 
    flex: 1; min-height: 0;
    overflow-y: auto; padding-bottom: 40px; padding-top: 5px;
}

.day-tile { 
    aspect-ratio: 1; border-radius: 14px; 
    display: flex; align-items: center; justify-content: center; 
    font-size: 15px; font-weight: 600; cursor: pointer; 
    transition: all 0.2s; background: var(--future); color: #A0A5A0; 
}
.day-tile.completed { background: var(--completed); color: white; box-shadow: 0 4px 10px rgba(63,90,64,0.2); }
.day-tile.missed { background: transparent; border: 2px solid var(--missed); color: var(--missed); }
.day-tile.today { border: 2px solid var(--primary); color: var(--primary); background: transparent; }
.day-tile:active { transform: scale(0.92); }

/* --- 기도문 화면 --- */
.prayer-header { 
    display: flex; justify-content: space-between; align-items: center; 
    margin-bottom: 30px; 
}
.icon-btn { 
    background: var(--card-bg); 
    width: 44px; height: 44px; 
    border-radius: 50%;
    color: var(--primary); 
    box-shadow: var(--shadow-sm);
}

.prayer-cards-container { flex: 1; display: flex; flex-direction: column; }
.card-progress { margin-bottom: 24px; display: flex; flex-direction: column; align-items: center; gap: 8px;}
.card-progress-text { font-size: 14px; font-weight: 600; color: var(--primary); letter-spacing: 2px;}
.card-progress-bar-bg { width: 100px; height: 4px; background: var(--future); border-radius: 4px; overflow: hidden;}
.card-progress-bar-fill { height: 100%; background: var(--primary); transition: width 0.3s ease; }

.prayer-card { 
    flex: 1; 
    padding: 40px 30px; 
    margin-bottom: 30px; 
    overflow-y: auto; 
    display: flex; flex-direction: column; justify-content: center; 
    min-height: 40vh;
}
#prayer-card-content {
    font-size: 18px; 
    line-height: 1.8; 
    color: var(--text-main); 
    white-space: pre-wrap; 
    word-break: keep-all; 
    text-align: center; 
    font-weight: 400;
}

.prayer-controls { display: flex; gap: 12px; margin-top: auto; padding-bottom: 20px;}
.nav-btn { flex: 1; }
.nav-btn:disabled { 
    background-color: var(--future); 
    color: #A0A5A0; 
    border: none;
    box-shadow: none; cursor: not-allowed; 
}
.finish-btn { 
    background-color: var(--accent); 
    color: #fff; 
    box-shadow: 0 8px 25px rgba(181, 117, 76, 0.3); 
    font-size: 18px; padding: 20px;
}
.finish-btn:hover { background-color: var(--accent-light); }
