:root {
    --primary: #4F46E5; --primary-hover: #4338CA; --primary-light: #EEF2FF;
    --bg: #F3F4F6; --surface: #FFFFFF; --text: #1F2937; --text-sub: #6B7280;
    --danger: #EF4444; --warn: #F59E0B; --success: #10B981;
    --input-bg: #F9FAFB; --friend-task-bg: #FFF0F7; --friend-task-border: #FBCFE8;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
* { font-family: 'Noto Sans KR', sans-serif; box-sizing: border-box; }
body { background-color: var(--bg); color: var(--text); margin: 0; display: flex; justify-content: center; min-height: 100vh; padding-bottom: 80px; }

/* 컨테이너 */
.container { width: 100%; max-width: 480px; background: var(--bg); display: none; flex-direction: column; gap: 16px; padding: 16px; }
.card { background: var(--surface); border-radius: 20px; padding: 20px; box-shadow: var(--shadow); border: 1px solid rgba(255,255,255,0.8); display: flex; flex-direction: column; gap: 12px; }
.card-title { font-size: 16px; font-weight: 800; color: var(--text); margin-bottom: 5px; display: flex; align-items: center; gap: 6px; }

/* 로그인 */
#auth-screen { position: fixed; inset: 0; background: var(--bg); z-index: 2000; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.auth-box { width: 90%; max-width: 360px; background: white; padding: 40px 30px; border-radius: 24px; box-shadow: 0 20px 40px rgba(0,0,0,0.08); text-align: center; }
.auth-logo { font-size: 26px; font-weight: 900; color: var(--primary); margin-bottom: 30px; letter-spacing: -0.5px; }
.auth-input { width: 100%; padding: 16px; margin-bottom: 12px; border: 1px solid #E5E7EB; background: #F9FAFB; border-radius: 14px; font-size: 15px; outline: none; transition: all 0.2s; }
.auth-input:focus { border-color: var(--primary); background: white; box-shadow: 0 0 0 4px var(--primary-light); }
.auth-btn { width: 100%; padding: 16px; background: var(--primary); color: white; border: none; border-radius: 14px; font-weight: 700; font-size: 16px; margin-top: 10px; margin-bottom: 20px; cursor: pointer; transition: 0.2s; box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3); }
.auth-btn:hover { background: var(--primary-hover); transform: translateY(-2px); }
.auth-link { color: var(--text-sub); font-size: 13px; text-decoration: underline; cursor: pointer; }

/* 헤더 */
.header-bar { display: flex; justify-content: space-between; align-items: center; padding: 10px 4px; }
.my-profile { display: flex; align-items: center; gap: 10px; cursor: pointer; background: var(--surface); padding: 5px 12px 5px 5px; border-radius: 30px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.my-thumb { width: 36px !important; height: 36px !important; min-width: 36px; border-radius: 50%; object-fit: cover; border: 2px solid var(--primary-light); background: #eee; }
.my-nick { font-weight: 700; font-size: 15px; color: var(--text); }
.noti-btn { position: relative; font-size: 20px; cursor: pointer; background: var(--surface); width: 40px; height: 40px; display: flex; justify-content: center; align-items: center; border-radius: 50%; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.noti-badge { position: absolute; top: -2px; right: -2px; background: var(--danger); color: white; font-size: 10px; padding: 2px 5px; border-radius: 10px; border: 2px solid white; }

/* 스토리 영역 */
.story-wrapper { position: relative; width: 100%; display: flex; align-items: center; }
.story-container { display: flex; overflow-x: auto; gap: 14px; padding: 5px 4px 15px 4px; scrollbar-width: none; scroll-behavior: smooth; flex: 1; }
.story-container::-webkit-scrollbar { display: none; }
.story-scroll-btn { display: none; background: rgba(255,255,255,0.8); border: 1px solid #ddd; border-radius: 50%; width: 32px; height: 32px; font-size: 18px; cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.1); z-index: 10; align-items: center; justify-content: center; flex-shrink: 0; }
.story-scroll-btn:hover { background: white; color: var(--primary); }
@media (hover: hover) and (pointer: fine) { .story-scroll-btn { display: flex; } }
.story-item { display: flex; flex-direction: column; align-items: center; cursor: pointer; min-width: 64px; position: relative; }
.story-ring { width: 60px; height: 60px; border-radius: 50%; padding: 3px; border: 2px solid transparent; display: flex; justify-content: center; align-items: center; background: var(--surface); box-shadow: 0 2px 8px rgba(0,0,0,0.05); transition: transform 0.2s; position: relative; }
.story-ring.active { border-color: var(--primary); transform: scale(1.05); }
.story-img { width: 100% !important; height: 100% !important; border-radius: 50%; object-fit: cover; background: #eee; }
.story-name { font-size: 11px; margin-top: 6px; color: var(--text-sub); width: 60px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.story-add { font-size: 24px; color: #ccc; }
.star-badge { position: absolute; bottom: 18px; right: 0; font-size: 16px; filter: drop-shadow(0 2px 2px rgba(0,0,0,0.2)); z-index: 10; animation: bounce 1.5s infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

/* 달력 */
.cal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding: 0 4px; }
.cal-title { font-size: 20px; font-weight: 800; color: var(--text); }
.cal-controls { display: flex; align-items: center; gap: 4px; }
.nav-btn { background: none; border: none; font-size: 24px; color: var(--text-sub); cursor: pointer; padding: 0 8px; line-height: 1; display: flex; align-items: center; }
.btn-today { border: 1px solid #ddd; background: white; padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; color: var(--text); cursor: pointer; transition: all 0.2s; white-space: nowrap; }
.btn-today:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.week-days { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 12px; color: var(--text-sub); margin-bottom: 8px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day-cell { aspect-ratio: 1/1; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; position: relative; background: #fff; border: 1px solid #f0f0f0; cursor: pointer; font-size: 13px; font-weight: 500; padding-top: 6px; overflow: hidden; transition: transform 0.1s; }
.day-cell:active { transform: scale(0.95); }
.day-cell.selected { border: 2px solid var(--primary); font-weight: 800; }
.day-cell.today { color: var(--primary); font-weight: 900; }
.day-num { z-index: 2; margin-bottom: 2px; }
.cell-icons { z-index: 2; display: flex; gap: 2px; justify-content: center; width: 100%; pointer-events: none; }
.status-icon { font-size: 10px; line-height: 1; }
.firework-icon { font-size: 12px; animation: pop 0.3s; }
.task-count-badge { position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%); font-size: 9px; font-weight: 800; color: #EF4444; line-height: 1; z-index: 5; }

/* 할 일 입력 */
.input-wrapper { display: flex; width: 100%; flex-direction: column; gap: 8px; margin-bottom: 15px; }
.task-input-row { display: flex; gap: 6px; width: 100%; align-items: center; }
.input-box { flex: 1; min-width: 0; padding: 12px; border: none; background: var(--input-bg); border-radius: 12px; font-size: 14px; outline: none; transition: background 0.2s; }
.input-box:focus { background: #EEF2FF; }
.btn-add, .btn-icon-toggle { width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.btn-add { background: var(--primary); color: white; border: none; font-size: 24px; box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3); }
.btn-icon-toggle { background: white; color: var(--text-sub); border: 1px solid #E5E7EB; font-size: 16px; }
.btn-icon-toggle.active { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
#repeat-options { background: #fff; padding: 12px; border-radius: 12px; border: 1px solid #eee; margin-top: 5px; }
.option-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 13px; color: #666; }
.mini-select, .mini-input { padding: 5px; border-radius: 6px; border: 1px solid #ddd; font-size: 13px; width: 60%; }

/* 리스트 아이템 */
.task-item { background: white; padding: 14px; border-radius: 14px; display: flex; flex-direction: column; gap: 4px; border: 1px solid #eee; margin-bottom: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.02); transition: transform 0.2s; }
.task-item.friend-task { background: var(--friend-task-bg); border-color: var(--friend-task-border); }
.task-top { display: flex; align-items: center; gap: 8px; min-height: 28px; }
.task-text { flex: 1; font-size: 14px; word-break: break-all; }
.completed .task-text { text-decoration: line-through; color: #aaa; }
.icon-btn { border: none; background: none; font-size: 15px; color: #888; cursor: pointer; padding: 2px; }
.author-badge { font-size: 10px; padding: 2px 6px; border-radius: 6px; background: #eee; color: #666; width: fit-content; }
.postpone-badge { font-size: 11px; background: #FEF3C7; color: #D97706; padding: 2px 6px; border-radius: 6px; width: fit-content; margin-top: 4px; }
.drag-handle { color: #ddd; font-size: 18px; cursor: grab; padding: 5px; }
.task-item.task-private { border: 2px dashed #9ca3af !important; background-color: #f8f9fa; position: relative; }
.task-item.task-private .task-text { color: #6b7280; }
.private-icon { color: var(--warn); margin-right: 4px; font-size: 14px; }

/* [NEW] 수정 모드 반응형 스타일 */
.edit-mode-wrapper { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: 100%; }
.task-edit-input { flex: 1; min-width: 150px; border: 1px solid var(--primary); border-radius: 8px; padding: 8px; font-size: 14px; outline: none; height: 36px; }
.edit-btn-group { display: flex; align-items: center; gap: 6px; flex-shrink: 0; margin-left: auto; }
.private-check-label { display: flex; align-items: center; cursor: pointer; font-size: 12px; white-space: nowrap; color: #666; margin-right: 4px; }
.btn-save-edit, .btn-cancel-edit { padding: 0 10px; height: 34px; border-radius: 8px; font-size: 13px; cursor: pointer; border: none; white-space: nowrap; }
.btn-save-edit { background: var(--primary); color: white; }
.btn-cancel-edit { background: #e5e7eb; color: #4b5563; }
@media (max-width: 350px) {
    .task-edit-input { min-width: 100%; margin-bottom: 6px; }
    .edit-mode-wrapper { justify-content: flex-end; }
}

/* 리뷰, 댓글 */
.review-input-container { background: var(--input-bg); border-radius: 14px; padding: 14px; border: 1px solid #eee; display: flex; flex-direction: column; gap: 10px; min-height: 120px; }
.review-textarea { width: 100%; flex: 1; border: none; background: transparent; font-size: 14px; resize: none; outline: none; }
.btn-submit { background: var(--primary); color: white; border: none; padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 700; width: 100%; box-shadow: 0 2px 8px rgba(79, 70, 229, 0.2); cursor: pointer; }
.review-content-box { background: var(--input-bg); padding: 20px; border-radius: 16px; font-size: 14px; line-height: 1.6; white-space: pre-wrap; min-height: 60px; }
.action-btn-edit { font-size: 13px; color: var(--primary); margin-right: 10px; cursor: pointer; font-weight: 600; }
.action-btn-del { font-size: 13px; color: var(--text-sub); cursor: pointer; }
.action-btn-del:hover { color: var(--danger); text-decoration: underline; }
.comment-item { display: flex; gap: 10px; margin-bottom: 12px; font-size: 13px; align-items: flex-start; }
.comment-avatar { display: block; width: 32px !important; height: 32px !important; min-width: 32px; border-radius: 50%; object-fit: cover; background: #eee; border: 1px solid #eee; }
.comment-bubble { background: var(--input-bg); padding: 8px 12px; border-radius: 0 14px 14px 14px; flex: 1; }
.comment-meta { display: flex; justify-content: space-between; margin-bottom: 3px; }
.comment-user { font-weight: 700; font-size: 12px; }
.reply-link { color: var(--text-sub); font-size: 11px; cursor: pointer; margin-left: 8px; }

/* 모달 공통 */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 3000; display: none; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
.modal-content { background: var(--surface); padding: 30px; border-radius: 24px; width: 85%; max-width: 340px; text-align: center; position: relative; box-shadow: 0 10px 40px rgba(0,0,0,0.2); max-height: 90vh; overflow-y: auto; }
.close-btn { position: absolute; top: 15px; right: 20px; font-size: 28px; font-weight: bold; color: #333; cursor: pointer; z-index: 3001; line-height: 1; }

/* 알림/프로필 모달 내부 */
.noti-section-title { font-size: 14px; font-weight: 700; color: var(--text-sub); text-align: left; margin-bottom: 8px; margin-top: 5px; }
.noti-list-box { max-height: 200px; overflow-y: auto; text-align: left; margin-bottom: 10px; }
.noti-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: #f9fafb; margin-bottom: 6px; cursor: pointer; transition: 0.2s; }
.noti-item:hover { background: #EEF2FF; }
.noti-thumb { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: #eee; flex-shrink: 0; }
.noti-content { flex: 1; font-size: 13px; }
.noti-user { font-weight: 700; color: var(--text); }
.noti-desc { color: var(--text-sub); display: block; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.noti-date { font-size: 11px; color: #aaa; margin-top: 2px; }
.btn-accept { background: var(--primary); color: white; border: none; padding: 6px 12px; border-radius: 8px; font-size: 12px; cursor: pointer; }

.edit-img-wrap { position: relative; display: inline-block; margin-bottom: 20px; }
.edit-img { width: 100px !important; height: 100px !important; border-radius: 50%; object-fit: cover; background: #eee; border: 4px solid white; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.cam-icon { position: absolute; bottom: 0; right: 0; background: var(--primary); color: white; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 3px solid white; cursor: pointer; }
.del-icon { position: absolute; bottom: 0; left: 0; background: var(--danger); color: white; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 3px solid white; cursor: pointer; }
.friend-list-box { margin-top: 25px; text-align: left; padding-top: 15px; border-top: 1px solid #eee; }
.friend-list-title { font-size: 14px; font-weight: 700; color: var(--text-sub); margin-bottom: 10px; }
.friend-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f5f5f5; }
.friend-info { display: flex; align-items: center; gap: 10px; }
.friend-thumb { width: 32px !important; height: 32px !important; border-radius: 50%; object-fit: cover; background: #eee; }
.friend-name { font-size: 13px; font-weight: 600; }
.btn-unfollow { font-size: 11px; padding: 4px 10px; border: 1px solid #ddd; background: white; color: #666; border-radius: 6px; cursor: pointer; }
.btn-unfollow:hover { border-color: var(--danger); color: var(--danger); background: #FFF5F5; }
.text-link { color: var(--text-sub); font-size: 13px; text-decoration: underline; cursor: pointer; }
.btn-invite { width: 100%; padding: 12px; background: #10B981; color: white; border: none; border-radius: 14px; font-weight: 700; font-size: 15px; cursor: pointer; margin-bottom: 20px; box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3); }
.btn-invite:hover { background: #059669; }

#loader { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(0,0,0,0.8); color: white; padding: 12px 24px; border-radius: 30px; z-index: 3000; font-size: 13px; }