/* ════════════════════════════════════════════════════════
   따봉챌린지 styles.css v1.0
════════════════════════════════════════════════════════ */

:root {
  /* ── 카카오톡 CI ───────────────────────────────────────
     Yellow  #FEE500 → 헤더·버튼·강조 배경
     Brown   #3A1D1D → 옐로우 위 텍스트·아이콘·다크버튼
  ─────────────────────────────────────────────────── */
  --primary:       #FEE500;   /* 카카오 옐로우 — 배경용 */
  --primary-light: #FFF9C4;   /* 연한 옐로우 — 그라디언트 끝 */
  --primary-dark:  #F0D800;   /* 진한 옐로우 — 그라디언트 시작 */
  --accent:        #3A1D1D;   /* 카카오 다크브라운 — 텍스트·아이콘·다크버튼 */
  --accent-light:  #6B3A3A;   /* 브라운 그라디언트 보조 */
  --accent-dark:   #1A0A0A;   /* 가장 짙은 브라운 */
  --surface:       #F5F5F5;   /* 카드·리스트 배경 */
  --surface2:      #EBEBEB;   /* 선택 상태·칩 배경 */
  --bg:            #FFFFFF;
  --text:          #191919;
  --muted:         #8B8B8B;
  --border:        #EDEDED;
  --green:         #2e7d32;
  --green-bg:      #e8f5e9;
  --red:           #c62828;
  --red-bg:        #fce4ec;
  --orange:        #e67e22;
  --orange-bg:     #fff3e0;
  --tab-height:    60px;
  --header-height: 52px;
  --radius:        14px;
  --radius-sm:     8px;
}

/* ── 기본 리셋 ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Segoe UI', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
ul { list-style: none; }
input, textarea, button { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; }
.hidden { display: none !important; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }

/* ── 온보딩 ───────────────────────────────────────────── */
#onboardingPanel {
  min-height: 100dvh;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
}
.onboarding-wrap {
  background: #fff;
  border-radius: 24px;
  padding: 32px 24px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0,0,0,0.25);
}
.onboarding-logo { font-size: 3.5rem; margin-bottom: 4px; }
.onboarding-title { font-size: 2rem; font-weight: 800; color: var(--accent); }
.onboarding-sub { font-size: 0.9rem; color: var(--muted); margin: 6px 0 20px; }
.onboarding-step { text-align: left; }
.onboarding-login-hint { font-size: 0.82rem; color: var(--muted); margin-top: 16px; }
.link-text { color: var(--accent); font-weight: 700; cursor: pointer; text-decoration: underline; }

/* 펫 선택 */
.pet-pick-label { font-size: 0.95rem; font-weight: 700; text-align: center; margin-bottom: 12px; }
.pet-pick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pet-opt {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 8px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.pet-opt.selected { border-color: var(--primary); background: var(--surface2); }
.pet-opt-icon { font-size: 2rem; }
.pet-opt-name { font-size: 0.8rem; font-weight: 700; margin-top: 4px; color: var(--accent); }
.muted-sm { font-size: 0.78rem; color: var(--muted); text-align: center; }

/* ── 앱 셸 ────────────────────────────────────────────── */
#appShell { display: flex; flex-direction: column; height: 100dvh; }

/* 헤더 */
.app-header {
  height: var(--header-height);
  background: var(--primary);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(58,29,29,0.15);
  z-index: 10;
}
.app-header-logo { font-size: 1.1rem; font-weight: 800; display: flex; align-items: center; gap: 6px; }
.app-version {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(58,29,29,0.12);
  border-radius: 20px;
  padding: 2px 7px;
  letter-spacing: 0.02em;
  vertical-align: middle;
}
.app-header-right { display: flex; align-items: center; gap: 8px; }
.header-ddageo {
  font-size: 0.85rem;
  font-weight: 700;
  background: rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 3px 10px;
}

/* 메인 스크롤 영역 */
.app-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
}

/* 탭 패널 */
.tab-panel { padding: 12px 12px 24px; }

/* 하단 탭바 */
.bottom-tabs {
  height: var(--tab-height);
  display: flex;
  border-top: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
  z-index: 10;
}
.btab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.65rem;
  color: var(--muted);
  padding: 6px 0;
  transition: color 0.15s;
}
.btab .material-symbols-outlined { font-size: 1.4rem; }
.btab.active { color: var(--accent); font-weight: 700; }

/* ── 공통 컴포넌트 ────────────────────────────────────── */

/* 버튼 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.9rem;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }
.btn-primary  { background: var(--primary); color: var(--accent); }        /* 옐로우+다크 — 카카오 CTA */
.btn-accent   { background: var(--accent); color: #fff; }                  /* 다크브라운+흰 — 보조 CTA */
.btn-outline  { background: #fff; color: var(--accent); border: 2px solid var(--accent); }
.btn-ghost    { background: var(--surface); color: var(--muted); }
.btn-full     { width: 100%; display: flex; }
.btn-sm       { padding: 7px 14px; font-size: 0.82rem; border-radius: var(--radius-sm); }
.btn-icon     { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--accent); background: rgba(58,29,29,0.08); }
.btn-icon:hover { background: rgba(58,29,29,0.16); }

/* 입력 */
.field-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; margin-top: 10px; }
.field-input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
  background: #fff;
}
.field-input:focus { border-color: var(--primary); }
textarea.field-input { resize: vertical; }

/* 섹션 헤더 */
.section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--accent);
  margin: 20px 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--primary);
}
.section-header .material-symbols-outlined { font-size: 1.2rem; }

/* 카드 리스트 */
.card-list { display: flex; flex-direction: column; gap: 8px; }
.card-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card-list li.empty {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 28px 16px;
  border: 1.5px dashed var(--border);
  background: var(--bg);
}

/* 폼 카드 */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 12px;
}
.form-card-title { font-size: 0.95rem; font-weight: 800; color: var(--accent); margin-bottom: 4px; }
.form-row { display: flex; gap: 10px; align-items: flex-end; }
.form-col { flex: 1; }

/* 힌트 */
.hint-text { font-size: 0.78rem; color: var(--muted); margin-top: 6px; min-height: 18px; }

/* 태그 */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
}
.tag-green  { background: var(--green-bg); color: var(--green); }
.tag-red    { background: var(--red-bg); color: var(--red); }
.tag-orange { background: var(--orange-bg); color: var(--orange); }
.tag-purple { background: var(--surface2); color: var(--accent); }
.tag-gray   { background: #f0f0f0; color: var(--muted); }

/* 서브 탭 */
.sub-tab-bar { display: flex; gap: 6px; margin-bottom: 12px; }
.sub-tab {
  flex: 1;
  padding: 9px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.sub-tab.active { background: var(--primary); color: var(--accent); border-color: var(--primary-dark); font-weight: 800; }

/* ── 홈 탭 컴포넌트 ───────────────────────────────────── */

/* 펫 카드 */
.pet-card {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}
.pet-emoji { font-size: 4rem; flex-shrink: 0; line-height: 1; }
.pet-info { flex: 1; min-width: 0; }
.pet-name { font-size: 1.1rem; font-weight: 800; }
.pet-level { font-size: 0.82rem; opacity: 0.85; margin-bottom: 8px; }
.xp-bar-wrap { }
.xp-bar-bg { background: rgba(255,255,255,0.3); border-radius: 4px; height: 10px; overflow: hidden; }
.xp-bar-fill { background: var(--primary); height: 100%; border-radius: 4px; transition: width 0.5s ease; }
.xp-label { font-size: 0.75rem; opacity: 0.85; margin-top: 5px; display: block; }

/* 요약 칩 */
.summary-row { display: flex; gap: 8px; margin-bottom: 12px; }
.summary-chip {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 6px 12px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.summary-chip .material-symbols-outlined { font-size: 1.4rem; color: var(--accent); }

/* 친구 피드 */
.feed-item { display: flex; align-items: center; gap: 10px; }
.feed-item .feed-icon { font-size: 1.4rem; flex-shrink: 0; }
.feed-item .feed-text { font-size: 0.85rem; flex: 1; }
.feed-item .feed-time { font-size: 0.72rem; color: var(--muted); }

/* ── 미션 카드 ────────────────────────────────────────── */
.mission-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 4px; }
.mission-card-title { font-weight: 700; font-size: 0.9rem; flex: 1; }
.mission-card-meta { font-size: 0.78rem; color: var(--muted); margin-bottom: 6px; }
.mission-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.mission-card-reward { font-size: 0.85rem; font-weight: 700; color: var(--accent); }

/* 친구 피커 */
.friend-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.friend-chip {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 2px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.friend-chip.selected { border-color: var(--primary-dark); background: var(--primary); color: var(--accent); }

/* ── 친구 탭 ─────────────────────────────────────────── */
.my-qr-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  margin-bottom: 12px;
}
.my-qr-label { font-size: 0.82rem; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.qr-image { width: 140px; height: 140px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.id-badge {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
  margin-top: 6px;
}

/* 친구 리스트 아이템 */
.friend-item { display: flex; align-items: center; gap: 12px; }
.friend-item-pet { font-size: 2rem; flex-shrink: 0; }
.friend-item-info { flex: 1; min-width: 0; }
.friend-item-name { font-weight: 700; font-size: 0.9rem; }
.friend-item-stats { font-size: 0.75rem; color: var(--muted); }

/* ── 따봉챌린지샵 잠금 ─────────────────────────────────────── */
.shop-locked { text-align: center; padding: 60px 24px; }
.shop-locked-icon { font-size: 4rem; margin-bottom: 12px; }
.shop-locked-title { font-size: 1.2rem; font-weight: 800; color: var(--accent); margin-bottom: 8px; }
.shop-locked-desc { font-size: 0.9rem; color: var(--muted); line-height: 1.6; }
.shop-locked-hint { font-size: 0.82rem; color: var(--muted); margin-top: 12px; }

/* ── 마이 탭 ─────────────────────────────────────────── */
.profile-card {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 20px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.profile-pet { font-size: 3rem; flex-shrink: 0; }
.profile-info { flex: 1; min-width: 0; }
.profile-name { font-size: 1.05rem; font-weight: 800; }
.profile-id { font-size: 0.78rem; opacity: 0.8; margin-top: 2px; }
.profile-stats { display: flex; gap: 16px; width: 100%; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.2); margin-top: 8px; }
.stat-item { text-align: center; flex: 1; }
.stat-value { display: block; font-size: 1.2rem; font-weight: 800; }
.stat-label { font-size: 0.72rem; opacity: 0.8; }

/* 따거 내역 */
.history-item { display: flex; justify-content: space-between; align-items: center; }
.history-reason { font-size: 0.85rem; flex: 1; }
.history-date { font-size: 0.78rem; color: var(--muted); margin-left: 12px; white-space: nowrap; }
.history-amount { font-size: 0.9rem; font-weight: 700; }
.history-amount.plus  { color: var(--green); }
.history-amount.minus { color: var(--red); }

/* ── 모달 ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  display: flex;
  align-items: flex-end;
}
.modal-sheet {
  background: #fff;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-size: 1rem; font-weight: 800; color: var(--accent); flex: 1; }
.modal-body { padding: 14px 16px 24px; overflow-y: auto; }
.modal-body .btn-icon { color: var(--text); background: var(--surface); }

/* ── 승인 대기 배지 ───────────────────────────────────── */
.pending-badge {
  background: var(--red);
  color: #fff;
  border-radius: 50%;
  width: 16px; height: 16px;
  font-size: 0.65rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── 진행 바 ──────────────────────────────────────────── */
.progress-bar-bg { background: var(--border); border-radius: 4px; height: 8px; overflow: hidden; margin: 4px 0; }
.progress-bar-fill { background: var(--primary); height: 100%; border-radius: 4px; }

/* ── 티켓 시스템 ──────────────────────────────────────── */
.ticket-type-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.ticket-type-btn {
  flex: 1;
  padding: 8px 6px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.ticket-type-btn.active {
  background: var(--primary);
  color: var(--accent);
  border-color: var(--primary-dark);
}

.ticket-card {
  background: var(--surface);
  border-radius: 12px;
  border: 1.5px solid var(--border);
  padding: 12px 14px;
  margin-bottom: 8px;
}
.ticket-card.ticket-custom   { border-left: 4px solid var(--primary); }
.ticket-card.ticket-gifticon { border-left: 4px solid var(--accent); }
.ticket-card.ticket-used     { opacity: 0.55; }
.ticket-card-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 4px; }
.ticket-card-meta  { font-size: 0.75rem; color: var(--muted); margin-bottom: 8px; }
.ticket-code-box {
  background: var(--surface2);
  border: 1px dashed var(--accent-dark);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-align: center;
  margin: 6px 0;
  word-break: break-all;
}
.ticket-status-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
}
.ticket-status-tag.available     { background: #e8f5e9; color: #2e7d32; }
.ticket-status-tag.use_requested { background: #fff3e0; color: #e65100; }
.ticket-status-tag.used          { background: #f5f5f5; color: #9e9e9e; }

.ticket-use-req-badge {
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  width: 16px; height: 16px;
  font-size: 0.65rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── 가이드 모달 ────────────────────────────────────────── */
.guide-sheet { max-height: 92dvh; display: flex; flex-direction: column; }
.guide-body  { padding: 0 0 32px; overflow-y: auto; flex: 1; }

.guide-section {
  border-bottom: 1px solid var(--border);
}
.guide-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 16px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.guide-summary::-webkit-details-marker { display: none; }
.guide-summary::after {
  content: "expand_more";
  font-family: 'Material Symbols Outlined';
  font-size: 20px;
  margin-left: auto;
  color: var(--muted);
  transition: transform 0.2s;
}
details[open] > .guide-summary::after { transform: rotate(180deg); }

.guide-content {
  padding: 4px 16px 16px;
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.6;
}
.guide-content p { margin-bottom: 8px; }
.guide-sub {
  font-weight: 700;
  color: var(--accent);
  margin-top: 12px;
  margin-bottom: 4px;
}
.guide-list {
  padding-left: 6px;
  margin-bottom: 8px;
}
.guide-list li {
  padding: 3px 0 3px 16px;
  position: relative;
}
.guide-list li::before {
  content: "•";
  position: absolute;
  left: 4px;
  color: var(--muted);
}
.guide-ol { counter-reset: guide-counter; }
.guide-ol li { padding-left: 24px; }
.guide-ol li::before {
  content: counter(guide-counter) ".";
  counter-increment: guide-counter;
  font-weight: 700;
  color: var(--accent);
  left: 2px;
}
.guide-tip {
  background: var(--surface);
  border-left: 3px solid var(--primary-dark);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 8px 12px;
  font-size: 0.82rem;
  color: var(--accent);
  margin: 8px 0;
}
.guide-warn {
  background: #fff3e0;
  border-left: 3px solid var(--orange);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 8px 12px;
  font-size: 0.82rem;
  color: var(--orange);
  margin: 8px 0;
}
.guide-table-wrap { overflow-x: auto; margin: 8px 0; }
.guide-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.guide-table th, .guide-table td {
  padding: 7px 10px;
  border: 1px solid var(--border);
  text-align: left;
}
.guide-table th { background: var(--surface2); font-weight: 700; color: var(--accent); }
.guide-table tr:nth-child(even) td { background: var(--surface); }
.guide-footer {
  text-align: center;
  padding: 20px 16px 8px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
}
code {
  background: var(--surface2);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.82rem;
  font-family: 'Courier New', monospace;
}

/* ── 저작자 푸터 ─────────────────────────────────────── */
.author-footer {
  margin-top: 28px;
  padding: 20px 0 8px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.author-logo {
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 8px;
}
.author-info {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.author-link {
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid var(--primary-dark);
  padding-bottom: 1px;
}
.author-link:hover { opacity: 0.7; }
.author-sep { color: var(--muted); font-size: 0.8rem; }
.author-copy {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 4px;
}

/* 온보딩 저작자 */
.onboarding-author {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.onboarding-author a {
  font-size: 0.75rem;
  color: var(--muted);
  text-decoration: none;
}
.onboarding-author a:hover { color: var(--accent); }

/* ── 반응형 (태블릿+ 640px~) ──────────────────────────── */
@media (min-width: 640px) {
  #appShell { max-width: 480px; margin: 0 auto; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
  #onboardingPanel { align-items: center; }
  .onboarding-wrap { max-width: 400px; }
}
