:root {
  --bg: #FFF6F1;
  --card: #FFFFFF;
  --pink: #F79CB8;
  --pink-deep: #EF6E9C;
  --pink-soft: #FDE7EE;
  --mint: #4FC4AF;
  --mint-soft: #E2F7F1;
  --coral: #F49A7A;
  --coral-soft: #FDEEE6;
  --text: #4A3B3E;
  --text-sub: #A9908F;
  --line: #F5E3DC;
  --shadow: 0 4px 16px rgba(239, 110, 156, .10);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  overscroll-behavior-y: none;
}
.hidden { display: none !important; }
button { font-family: inherit; border: none; background: none; cursor: pointer; color: inherit; }
input { font-family: inherit; color: var(--text); }

/* ── PIN ── */
.pin-gate {
  position: fixed; inset: 0; background: var(--bg); z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.pin-box { text-align: center; padding: 32px; }
.pin-emoji { font-size: 44px; margin-bottom: 12px; }
.pin-box h2 { font-size: 22px; margin-bottom: 6px; }
.pin-box p { color: var(--text-sub); font-size: 14px; margin-bottom: 20px; }
.pin-box input {
  width: 160px; text-align: center; font-size: 28px; letter-spacing: 12px;
  padding: 12px; border: none; border-radius: 16px; background: #fff;
  box-shadow: var(--shadow); outline: none;
}
.pin-error { color: var(--coral); font-size: 13px; margin-top: 12px; height: 18px; }

/* ── 레이아웃 ── */
.app { max-width: 480px; margin: 0 auto; height: 100dvh; overflow: hidden; }
.views {
  display: flex; width: 200%; height: 100%;
  transition: transform .3s ease;
}
.views.cal { transform: translateX(-50%); }
.view {
  width: 50%; height: 100%; overflow-y: auto; padding: 20px 20px 110px;
  padding-top: calc(20px + env(safe-area-inset-top));
}

.top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.today-label { font-size: 13px; color: var(--pink-deep); font-weight: 700; }
.top h1 { font-size: 20px; font-weight: 800; }
.top-btns { display: flex; gap: 6px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 14px; background: #fff;
  box-shadow: var(--shadow); font-size: 17px; transition: transform .1s;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:active { transform: scale(.94); }

/* ── 카드 ── */
.card { background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 20px; }

.weight-card { text-align: center; margin-bottom: 24px; }
.weight-deco { font-size: 13px; font-weight: 700; color: var(--pink-deep); margin-bottom: 10px; }
.weight-main { display: flex; align-items: baseline; justify-content: center; gap: 6px; }
.weight-num { font-size: 44px; font-weight: 800; line-height: 1; }
.weight-unit { font-size: 16px; color: var(--text-sub); font-weight: 600; }
.diff-badge {
  align-self: center; font-size: 13px; font-weight: 800;
  padding: 4px 10px; border-radius: 999px; margin-left: 4px;
}
.diff-badge.down { background: var(--mint-soft); color: var(--mint); }
.diff-badge.up { background: var(--coral-soft); color: var(--coral); }
.diff-badge.same { background: var(--pink-soft); color: var(--pink-deep); }
.weight-prev { font-size: 13px; color: var(--text-sub); margin-top: 8px; min-height: 18px; }

.btn-main {
  width: 100%; margin-top: 16px; padding: 14px; border-radius: 999px;
  background: linear-gradient(135deg, var(--pink), var(--pink-deep));
  color: #fff; font-size: 15px; font-weight: 800;
  box-shadow: 0 6px 14px rgba(239, 110, 156, .3); transition: transform .1s;
}
.btn-main:active { transform: scale(.97); }
.btn-del { width: 100%; margin-top: 10px; padding: 12px; border-radius: 999px; color: var(--coral); font-weight: 700; font-size: 14px; }

/* ── 식사 ── */
.meals-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.meals-head h2 { font-size: 17px; font-weight: 800; }
.kcal-total { font-size: 13px; font-weight: 800; color: var(--pink-deep); background: var(--pink-soft); padding: 5px 12px; border-radius: 999px; }
.meal-list { display: flex; flex-direction: column; gap: 10px; }
.meal-item {
  background: #fff; border-radius: 18px; box-shadow: var(--shadow);
  padding: 14px 16px; display: flex; align-items: center; gap: 12px;
  transition: transform .1s;
}
.meal-item:active { transform: scale(.98); }
.meal-time {
  font-size: 12px; font-weight: 800; color: var(--pink-deep);
  background: var(--pink-soft); padding: 5px 9px; border-radius: 10px; white-space: nowrap;
}
.meal-content { flex: 1; font-size: 15px; font-weight: 600; word-break: break-all; }
.meal-kcal { font-size: 12px; color: var(--text-sub); font-weight: 700; white-space: nowrap; }
.meal-empty { text-align: center; color: var(--text-sub); font-size: 14px; line-height: 1.7; padding: 36px 0; }

.fab {
  position: fixed; right: calc(50% - 240px + 20px); bottom: calc(24px + env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--pink-deep));
  color: #fff; font-size: 30px; font-weight: 600; line-height: 1;
  box-shadow: 0 8px 20px rgba(239, 110, 156, .4); z-index: 20;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s;
}
@media (max-width: 480px) { .fab { right: 20px; } }
.fab:active { transform: scale(.92); }

/* ── 달력 ── */
.cal-nav { display: flex; align-items: center; gap: 4px; }
.cal-nav h1 { font-size: 18px; min-width: 110px; text-align: center; }
.cal-card { padding: 16px 10px; }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 12px; font-weight: 700; color: var(--text-sub); margin-bottom: 8px; }
.cal-week .sun { color: var(--coral); }
.cal-week .sat { color: #7FB5E8; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 6px; }
.cal-cell { text-align: center; padding: 4px 0; border-radius: 12px; min-height: 46px; }
.cal-cell.tappable:active { background: var(--pink-soft); }
.cal-day { font-size: 13px; font-weight: 700; }
.cal-cell.today .cal-day {
  display: inline-flex; width: 22px; height: 22px; align-items: center; justify-content: center;
  background: var(--pink-deep); color: #fff; border-radius: 50%;
}
.cal-w { font-size: 10.5px; font-weight: 800; margin-top: 2px; color: var(--text-sub); }
.cal-w.down { color: var(--mint); }
.cal-hint { display: flex; align-items: center; gap: 6px; justify-content: center; font-size: 12px; color: var(--text-sub); margin-top: 14px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.mint { background: var(--mint); }

/* ── 시트 ── */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-bg { position: absolute; inset: 0; background: rgba(74, 59, 62, .35); }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-width: 480px; margin: 0 auto;
  background: #fff; border-radius: 24px 24px 0 0; padding: 24px 24px calc(28px + env(safe-area-inset-bottom));
  animation: slideup .25s ease-out;
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet h3 { font-size: 18px; font-weight: 800; margin-bottom: 16px; }
.sheet input[type=text], .sheet input[type=number], .sheet input[type=time] {
  width: 100%; padding: 13px 16px; border: 2px solid var(--line); border-radius: 16px;
  font-size: 16px; outline: none; background: var(--bg);
}
.sheet input:focus { border-color: var(--pink); }
.weight-input-row { display: flex; align-items: center; gap: 10px; }
.weight-input-row input { text-align: center; font-size: 24px; font-weight: 800; }
.weight-input-row span { font-weight: 700; color: var(--text-sub); }
.meal-sub-row { display: flex; gap: 10px; margin-top: 10px; }
.meal-sub-row input[type=time] { flex: 1; }
.kcal-edit { flex: 1; display: flex; align-items: center; gap: 6px; }
.kcal-edit span { font-size: 13px; color: var(--text-sub); font-weight: 700; }

.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.setting-name { font-size: 15px; font-weight: 700; }
.setting-desc { font-size: 12.5px; color: var(--text-sub); margin-top: 3px; }
.setting-note { font-size: 12px; color: var(--text-sub); margin-top: 16px; line-height: 1.5; }
.btn-mini {
  padding: 8px 16px; border-radius: 999px; background: var(--pink-soft);
  color: var(--pink-deep); font-weight: 800; font-size: 13px; flex-shrink: 0;
}
.toggle {
  width: 52px; height: 30px; border-radius: 999px; background: var(--line);
  position: relative; transition: background .2s; flex-shrink: 0;
}
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.15); transition: left .2s;
}
.toggle.on { background: var(--pink-deep); }
.toggle.on::after { left: 25px; }

/* 날짜 상세 */
.day-weight { text-align: center; font-size: 26px; font-weight: 800; margin-bottom: 4px; }
.day-diff { text-align: center; margin-bottom: 14px; }
.day-meals { display: flex; flex-direction: column; gap: 8px; max-height: 40vh; overflow-y: auto; }
.day-empty { text-align: center; color: var(--text-sub); font-size: 14px; padding: 16px 0; }

.toast {
  position: fixed; bottom: calc(100px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; font-size: 13.5px; font-weight: 600;
  padding: 10px 18px; border-radius: 999px; z-index: 90; white-space: nowrap;
}
