/* ===== 글로벌 리셋 & 기본 변수 ===== */
:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --primary-ring: rgba(79, 70, 229, 0.2);
  
  --secondary: #0ea5e9;
  --secondary-light: #f0f9ff;
  
  --success: #10b981;
  --success-light: #ecfdf5;
  
  --sunday: #f43f5e;
  --sunday-light: #fff1f2;
  --saturday: #3b82f6;
  --saturday-light: #eff6ff;

  --bg: #f8fafc;
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --code-bg: #1e293b;
  --code-text: #f1f5f9;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
  --shadow-modal: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  padding: 24px 16px 60px;
}

.code-font {
  font-family: 'JetBrains Mono', Consolas, Monaco, monospace !important;
}

/* ===== 앱 레이아웃 컨테이너 ===== */
.app-container {
  max-width: 860px;
  margin: 0 auto;
}

/* ===== 상단 네비게이션 헤더 ===== */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 4px 20px;
  flex-wrap: wrap;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  color: white;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.brand-title {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.brand-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 6px;
  background: white;
  border: 1px solid var(--card-border);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  background-color: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--success-light);
}

.status-dot.offline {
  background-color: #f59e0b;
  box-shadow: 0 0 0 2px #fef3c7;
}

/* 안내 팁 바 */
.info-tip-bar {
  background: linear-gradient(90deg, #f5f3ff, #eef2ff);
  border: 1px solid #e0e7ff;
  border-radius: var(--radius-md);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  font-size: 0.88rem;
  color: #3730a3;
  box-shadow: var(--shadow-sm);
}

.tip-badge {
  background-color: var(--primary);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  letter-spacing: 0.05em;
}

.tip-text strong {
  color: #1e1b4b;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ===== 상단 미니 캘린더 카드 ===== */
.calendar-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-md);
  margin-bottom: 28px;
  position: relative;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.calendar-title-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.calendar-month-year {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.quick-nav-pills {
  display: flex;
  gap: 6px;
}

.pill-btn {
  background: #f1f5f9;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
}

.pill-btn:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.pill-btn.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: #c7d2fe;
}

.calendar-controls {
  display: flex;
  gap: 6px;
}

.nav-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: white;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.nav-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

/* 달력 그리드 */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.weekdays {
  margin-bottom: 8px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 6px;
}

.weekday {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 0;
}

.weekday.sun { color: var(--sunday); }
.weekday.sat { color: var(--saturday); }

/* 달력 날짜 셀 */
.calendar-day-cell {
  position: relative;
  height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-main);
}

.calendar-day-cell:hover:not(.empty) {
  background-color: #f8fafc;
  transform: translateY(-1px);
}

.calendar-day-cell.empty {
  cursor: default;
  color: #cbd5e1;
  opacity: 0.35;
}

.calendar-day-cell.is-sun {
  color: var(--sunday);
}

.calendar-day-cell.is-sat {
  color: var(--saturday);
}

/* 오늘 날짜 표시 */
.calendar-day-cell.is-today .day-number {
  border: 1.5px solid var(--primary);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 선택된 날짜 표시 */
.calendar-day-cell.is-selected {
  background-color: var(--primary) !important;
  color: white !important;
  font-weight: 700;
  box-shadow: 0 4px 8px rgba(79, 70, 229, 0.35);
}

.calendar-day-cell.is-selected .is-sun,
.calendar-day-cell.is-selected .is-sat,
.calendar-day-cell.is-selected .day-number {
  color: white !important;
  border-color: transparent !important;
}

/* 프롬프트 기록 있는 날짜 표시 */
.calendar-day-cell.has-prompt .prompt-indicator {
  position: absolute;
  bottom: 4px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.prompt-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #ec4899;
}

.calendar-day-cell.is-selected .prompt-dot {
  background-color: #fbcfe8;
}

.prompt-count-pill {
  font-size: 0.65rem;
  font-weight: 700;
  background-color: #ec4899;
  color: white;
  border-radius: 10px;
  padding: 0 4px;
  height: 14px;
  line-height: 14px;
}

.calendar-day-cell.is-selected .prompt-count-pill {
  background-color: white;
  color: var(--primary);
}

/* 달력 하단 범례 */
.calendar-footer {
  display: flex;
  gap: 16px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-badge-weekend {
  background: #f1f5f9;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
}

/* ===== 하단 프롬프트 섹션 ===== */
.prompts-section {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.selected-date-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.date-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.date-badge svg {
  color: var(--primary);
}

.count-badge {
  background-color: var(--primary-light);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.text-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--transition);
  padding: 4px;
}

.text-action-btn:hover {
  color: var(--primary);
}

.divider {
  color: #cbd5e1;
  font-size: 0.8rem;
}

/* 타임라인 목록 */
.prompt-timeline {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
}

/* 프롬프트 카드 */
.prompt-card {
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  background: white;
  overflow: hidden;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.prompt-card:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-md);
}

.prompt-card.is-open {
  border-color: #c7d2fe;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.08);
}

/* 카드 헤더 (클릭 가능한 토글 버튼 영역) */
.prompt-card-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  background-color: white;
  transition: background-color 0.15s ease;
  user-select: none;
  gap: 16px;
}

.prompt-card-header:hover {
  background-color: #f8fafc;
}

.prompt-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
}

.prompt-time-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #475569;
  background: #f1f5f9;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.prompt-title-text {
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.01em;
  line-height: 1.4;
}

.toggle-arrow {
  color: var(--text-light);
  display: flex;
  align-items: center;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.prompt-card.is-open .toggle-arrow {
  transform: rotate(180deg);
  color: var(--primary);
}

/* 카드 상세 본문 (토글 확장 영역) */
.prompt-card-body {
  display: none;
  padding: 0 20px 20px;
  border-top: 1px solid #f1f5f9;
  background-color: #fafbfc;
}

.prompt-card.is-open .prompt-card-body {
  display: block;
  animation: fadeInDown 0.2s ease-out;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 블록 헤더 */
.detail-block {
  margin-top: 18px;
}

.block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.block-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 복사 버튼 */
.copy-btn {
  background: white;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: var(--transition);
}

.copy-btn:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.copy-btn.copied {
  background: var(--success-light);
  color: var(--success);
  border-color: #a7f3d0;
}

/* 프롬프트 코드 박스 */
.prompt-box {
  background-color: var(--code-bg);
  color: var(--code-text);
  padding: 16px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid #334155;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* 설명 박스 */
.description-box {
  background-color: #f1f5f9;
  border-left: 4px solid var(--primary);
  padding: 14px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.9rem;
  color: #334155;
  line-height: 1.6;
  white-space: pre-wrap;
}

.empty-desc {
  font-style: italic;
  color: var(--text-light);
}

/* 카드 액션 (수정 버튼 등) */
.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px dashed #e2e8f0;
}

.btn-edit {
  background: white;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-edit:hover {
  background: #f8fafc;
  border-color: var(--primary);
  color: var(--primary);
}

/* 비어있는 날짜 안내 */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state-icon {
  width: 56px;
  height: 56px;
  background: #f1f5f9;
  color: #94a3b8;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.empty-state-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.empty-state-desc {
  font-size: 0.88rem;
  line-height: 1.5;
  max-width: 420px;
  margin: 0 auto 18px;
}

/* ===== 버튼 공통 스타일 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.86rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  border: none;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: #f1f5f9;
  color: #475569;
}

.btn-secondary:hover {
  background-color: #e2e8f0;
  color: var(--text-main);
}

.btn-outline {
  background: white;
  border: 1px solid var(--card-border);
  color: var(--text-main);
}

.btn-outline:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

/* ===== 모달 팝업 레이아웃 ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: white;
  width: 100%;
  max-width: 580px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: scaleUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleUp {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 4px;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.8rem;
  color: var(--text-light);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: var(--transition);
}

.modal-close-btn:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.form-group {
  margin-bottom: 18px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.flex-1 {
  flex: 1;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-input,
.form-textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--text-main);
  font-family: inherit;
  transition: var(--transition);
  background: white;
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background-color: #fafbfc;
}

/* 가이드 모달 */
.guide-content {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.guide-step {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.step-num {
  width: 28px;
  height: 28px;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.88rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.guide-step h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}

.guide-step p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ===== 토스트 알림 ===== */
.toast-message {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background-color: #1e293b;
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-message.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ===== 반응형 미디어 쿼리 ===== */
@media (max-width: 640px) {
  body {
    padding: 16px 10px 40px;
  }

  .calendar-card,
  .prompts-section {
    padding: 16px;
  }

  .calendar-day-cell {
    height: 42px;
    font-size: 0.82rem;
  }

  .prompt-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .prompt-header-left {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .form-row {
    flex-direction: column;
    gap: 14px;
  }
}
