:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1c2030;
  --ink-soft: #5b6178;
  --line: #e6e9ef;
  --primary: #00b894;
  --primary-soft: #d4f5ea;
  --accent: #f6c945;
  --warn: #ff7849;
  --shadow: 0 4px 16px rgba(20, 30, 60, 0.06);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Apple SD Gothic Neo", "Pretendard", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 22px 18px 60px;
}

/* 상단 */
.topbar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
  gap: 14px; margin-bottom: 14px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 44px; height: 44px;
  background: var(--primary-soft);
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 22px;
}
.brand h1 { margin: 0; font-size: 20px; }
.subtitle { margin: 2px 0 0; color: var(--ink-soft); font-size: 13px; }

.hud {
  display: flex; gap: 8px;
  background: white; padding: 6px; border-radius: 12px; box-shadow: var(--shadow);
}
.hud-cell {
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 14px;
  border-right: 1px solid var(--line);
}
.hud-cell:last-child { border-right: none; }
.hud-cell b { font-size: 16px; }
.hud-cell small { font-size: 11px; color: var(--ink-soft); margin-top: 2px; }

/* 탭 */
.tabs { display: flex; gap: 4px; background: #fff; padding: 4px; border-radius: 12px; box-shadow: var(--shadow); margin-bottom: 18px; }
.tab {
  flex: 1;
  border: none; background: transparent;
  padding: 10px; border-radius: 8px;
  cursor: pointer; font-size: 14px; color: var(--ink-soft);
  font-weight: 500;
}
.tab.active { background: var(--primary); color: white; }

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* 카드 공통 */
.check-in-card, .missions-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.check-in-card h2, .missions-card h2 { margin: 0 0 6px; font-size: 17px; }
.hint { color: var(--ink-soft); font-size: 13px; margin: 0 0 14px; line-height: 1.5; }

/* 체크인 */
.mood-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.mood-label { font-size: 13px; color: var(--ink-soft); width: 64px; flex-shrink: 0; }
.mood-buttons { display: flex; gap: 4px; flex: 1; }
.mood-buttons button {
  flex: 1;
  background: #f7f8fb;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px;
  font-size: 22px;
  cursor: pointer;
}
.mood-buttons button.on {
  background: var(--primary-soft);
  border-color: var(--primary);
}
.mood-row input[type="text"] {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
}

/* 미션 */
.missions-head {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;
}
.missions-head h2 { display: flex; gap: 8px; align-items: center; }
.lvtag {
  font-size: 12px; font-weight: 600;
  background: var(--accent); color: #6a4900;
  padding: 3px 10px; border-radius: 12px;
}
.rec-banner {
  background: var(--primary-soft); color: #006a55;
  padding: 10px 12px; border-radius: 10px;
  font-size: 13px; line-height: 1.5; margin: 8px 0 12px;
}

.mission-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 8px;
  background: #fcfdff;
  transition: all 0.2s;
}
.mission-row.done { background: var(--primary-soft); border-color: var(--primary); }
.mission-row .check {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: white;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
  display: grid; place-items: center;
  font-size: 14px;
  color: white;
}
.mission-row.done .check {
  background: var(--primary);
  border-color: var(--primary);
}
.mission-row .body { flex: 1; }
.mission-row .body .nm { font-weight: 600; font-size: 14px; }
.mission-row .body .meta { font-size: 11px; color: var(--ink-soft); margin-top: 4px; }
.mission-row .body input.note {
  width: 100%; margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  background: white;
}
.mission-row.done .body input.note { background: white; }

.rec-explainer {
  background: #fff7ea;
  border: 1px solid #ffe1a8;
  color: #7d4f00;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 16px;
}

/* 출석부 */
.calendar-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin-bottom: 18px;
}
.kpi {
  background: white; border-radius: 12px; box-shadow: var(--shadow);
  padding: 14px; text-align: center;
}
.kpi b { display: block; font-size: 22px; }
.kpi small { color: var(--ink-soft); font-size: 12px; margin-top: 2px; display: block; }

.calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  background: white; padding: 14px; border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.cal-cell {
  aspect-ratio: 1;
  border-radius: 8px;
  background: #f1f3f7;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-size: 11px; color: var(--ink-soft);
  position: relative;
}
.cal-cell.future { opacity: 0.4; }
.cal-cell.attend { background: var(--primary-soft); color: #006a55; }
.cal-cell.attend::after {
  content: "✓"; position: absolute; top: 2px; right: 4px;
  color: var(--primary); font-weight: bold; font-size: 11px;
}
.cal-cell.today { box-shadow: 0 0 0 2px var(--primary); }
.cal-cell .pct { font-size: 9px; opacity: 0.7; }

.bar-chart {
  display: flex; gap: 6px; align-items: flex-end;
  height: 120px;
  background: white; padding: 14px; border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.bar-chart .bar {
  flex: 1;
  background: var(--primary);
  border-radius: 6px 6px 0 0;
  position: relative;
  min-height: 4px;
}
.bar-chart .bar small {
  position: absolute; bottom: -18px; left: 0; right: 0; text-align: center;
  font-size: 10px; color: var(--ink-soft);
}

/* 보상 */
.draw-zone {
  background: white; border-radius: var(--radius); padding: 24px;
  text-align: center; box-shadow: var(--shadow);
}
.btn-primary.big { padding: 14px 28px; font-size: 16px; }

.drawn-card {
  margin-top: 20px;
  background: linear-gradient(135deg, #fed967 0%, #f6a945 100%);
  color: #4a2900;
  padding: 26px 18px;
  border-radius: 14px;
  font-size: 18px;
  line-height: 1.5;
  box-shadow: 0 12px 30px rgba(246, 169, 69, 0.3);
}
.drawn-card .emoji { font-size: 40px; margin-bottom: 10px; }
.drawn-card.hidden { display: none; }

.badge-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.badge {
  background: white; border-radius: 10px; padding: 14px 8px;
  text-align: center; box-shadow: var(--shadow);
  position: relative;
}
.badge.locked { opacity: 0.35; }
.badge .ico { font-size: 32px; }
.badge .nm { font-weight: 600; font-size: 12px; margin-top: 6px; }
.badge .desc { font-size: 10px; color: var(--ink-soft); margin-top: 2px; }

.level-progress {
  background: white; padding: 18px; border-radius: var(--radius); box-shadow: var(--shadow);
}
.level-progress .lvl-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.level-progress .lvl-row:last-child { border: none; }
.level-progress .lvl-row .ico { font-size: 24px; width: 36px; text-align: center; }
.level-progress .lvl-row .info { flex: 1; }
.level-progress .lvl-row .info b { font-size: 14px; }
.level-progress .lvl-row .info small { color: var(--ink-soft); font-size: 12px; display: block; }
.level-progress .lvl-row .stat { font-weight: 600; font-size: 14px; }
.level-progress .lvl-row.locked { opacity: 0.4; }
.level-progress .lvl-row.current { background: var(--primary-soft); border-radius: 8px; padding: 10px; }

/* 설정 폼 */
.form-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  background: var(--card); padding: 16px; border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.form-grid label span { font-weight: 600; color: var(--ink); }
.form-grid input[type="range"] { padding: 8px 0; }
.form-grid select {
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font-size: 14px; background: #fff; color: var(--ink);
}
.range-hint { font-size: 11px; }

.actions { display: flex; gap: 8px; margin-top: 14px; align-items: center; }
.save-toast {
  display: inline-block; opacity: 0; padding: 6px 12px;
  background: var(--primary); color: white; border-radius: 8px;
  font-size: 13px; transition: opacity 0.3s;
}
.save-toast.show { opacity: 1; }

.info-box {
  margin-top: 22px;
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.info-box h3 { margin: 0 0 10px; font-size: 15px; }
.info-box ul { margin: 0; padding-left: 4px; list-style: none; }
.info-box li { font-size: 13px; line-height: 1.7; color: var(--ink-soft); }

/* 버튼 */
.btn-primary, .btn-ghost {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #00997b; }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn-ghost:hover { background: #fff; color: var(--ink); }

.foot { text-align: center; margin-top: 30px; color: var(--ink-soft); }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .hud { width: 100%; justify-content: space-around; }
  .calendar-stats { grid-template-columns: repeat(3, 1fr); }
  .kpi b { font-size: 18px; }
}
