:root {
  --bg: #f6efe3;
  --card: #fffaf2;
  --ink: #3b3127;
  --ink-2: #7d6f5f;
  --line: #e4d7c3;
  --moca: #d9b77a;
  --moca-dark: #b48c3f;
  --accent: #e2834a;
  --good: #7fae5c;
  --grass-0: #efe6d6;
  --grass-1: #e2d39a;
  --grass-2: #cdb96a;
  --grass-3: #b89b3f;
  --grass-4: #9a7a1e;
  --radius: 16px;
  --tab-h: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }
body { font-family: "Gowun Dodum", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif; font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3, .jua { font-family: "Jua", "Gowun Dodum", sans-serif; font-weight: 400; margin: 0; }
h2 { font-size: 22px; } h3 { font-size: 18px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

#app { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); background: var(--bg); border-bottom: 1px solid var(--line); }
.topbar-title { font-family: "Jua", sans-serif; font-size: 20px; }
.logo { font-size: 22px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); font-family: "Jua", sans-serif; }

.view { flex: 1; padding: 16px; padding-bottom: calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); max-width: 560px; width: 100%; margin: 0 auto; }

.tabbar { position: fixed; bottom: 0; left: 0; right: 0; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: flex; background: var(--card); border-top: 1px solid var(--line); z-index: 10; }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; color: var(--ink-2); }
.tabbar a.active { color: var(--moca-dark); font-weight: 700; }
.tab-ico { font-size: 22px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card h3 { margin-bottom: 10px; }
.muted { color: var(--ink-2); font-size: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.chip { display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--grass-0); font-size: 13px; color: var(--ink-2); }
.chip.accent { background: #fbe6d6; color: #a8521f; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); cursor: pointer; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-family: "Jua", sans-serif; font-size: 18px; }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; }

.hero { display: flex; gap: 14px; align-items: center; }
.hero .avatar { width: 84px; height: 84px; border-radius: 50%; background: var(--moca); display: flex; align-items: center; justify-content: center; font-size: 44px; overflow: hidden; flex-shrink: 0; }
.hero .avatar img { width: 100%; height: 100%; object-fit: cover; }
.hero .big { font-family: "Jua", sans-serif; font-size: 26px; line-height: 1.2; }
.stats { display: flex; gap: 8px; margin-top: 10px; }
.stat { flex: 1; text-align: center; background: var(--grass-0); border-radius: 12px; padding: 8px 4px; }
.stat b { display: block; font-family: "Jua", sans-serif; font-size: 22px; color: var(--moca-dark); }
.stat span { font-size: 12px; color: var(--ink-2); }

.check { display: flex; align-items: center; gap: 12px; padding: 12px 10px; border-radius: 12px; border: 1px solid var(--line); background: #fff; cursor: pointer; user-select: none; }
.check + .check { margin-top: 8px; }
.check .box { width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--moca); display: flex; align-items: center; justify-content: center; font-size: 18px; color: #fff; flex-shrink: 0; }
.check.done .box { background: var(--good); border-color: var(--good); }
.check.done .label { text-decoration: line-through; color: var(--ink-2); }
.check .label { flex: 1; }
.check .why { font-size: 13px; color: var(--ink-2); background: var(--grass-0); border: 0; border-radius: 999px; padding: 4px 10px; }
.why-text { font-size: 13px; color: var(--ink-2); padding: 6px 10px 0 50px; }

.progress { height: 10px; background: var(--grass-0); border-radius: 999px; overflow: hidden; margin: 10px 0; }
.progress > div { height: 100%; background: var(--good); border-radius: 999px; transition: width .3s; }

.banner { background: #fbe6d6; border: 1px solid #f0c9ae; color: #8a3f12; border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; }

/* 기록 폼 */
.field { margin-bottom: 16px; }
.field > label { display: block; font-family: "Jua", sans-serif; font-size: 16px; margin-bottom: 8px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button { min-height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.seg button.on { background: var(--moca); border-color: var(--moca-dark); color: #2d2416; font-weight: 700; }
.seg.emoji button { font-size: 24px; padding: 0 10px; }
input[type=text], input[type=number], input[type=date], textarea, select { width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
textarea { min-height: 72px; resize: vertical; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline input, .inline select, .inline .half { flex: 1; min-width: 0; }
.inline > span, .inline > button { flex: 0 0 auto; }
.half { display: flex; flex-direction: column; gap: 4px; }
.mini { font-size: 12px; color: var(--ink-2); padding-left: 4px; }
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-outer-spin-button, input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.sticky-save { position: sticky; bottom: calc(var(--tab-h) + 12px + env(safe-area-inset-bottom)); }
.photos { display: flex; gap: 8px; flex-wrap: wrap; }
.photos .ph { width: 96px; height: 96px; border-radius: 12px; overflow: hidden; position: relative; background: var(--grass-0); }
.photos .ph img { width: 100%; height: 100%; object-fit: cover; }
.photos .ph button { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.5); color: #fff; }
.photos .add { width: 96px; height: 96px; border-radius: 12px; border: 2px dashed var(--moca); background: transparent; font-size: 28px; color: var(--moca-dark); }
.hint { font-size: 13px; color: var(--ink-2); margin-top: 6px; }

/* 달력 */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-grid .dow { text-align: center; font-size: 12px; color: var(--ink-2); }
.cal-cell { aspect-ratio: 1; border-radius: 10px; background: var(--grass-0); display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.cal-cell.l1 { background: var(--grass-1); } .cal-cell.l2 { background: var(--grass-2); color: #fff; }
.cal-cell.l3 { background: var(--grass-3); color: #fff; } .cal-cell.l4 { background: var(--grass-4); color: #fff; }
.cal-cell.today { outline: 2px solid var(--accent); }
.cal-cell.future { opacity: .35; cursor: default; }
.cal-cell.empty { background: transparent; cursor: default; }
.legend { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--ink-2); margin-top: 8px; justify-content: flex-end; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }

/* 모카 탭 */
.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.badge { text-align: center; padding: 10px 6px; border-radius: 12px; background: #fff; border: 1px solid var(--line); }
.badge .ico { font-size: 30px; }
.badge .name { font-size: 12px; margin-top: 4px; }
.badge.locked { opacity: .35; filter: grayscale(1); }
.album { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.album img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; }
.timeline li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
ul.timeline { list-style: none; padding: 0; margin: 0; }
.dots { display: flex; gap: 4px; flex-wrap: wrap; }
.dots i { width: 18px; height: 18px; border-radius: 50%; background: var(--grass-0); display: inline-block; }
.dots i.fed { background: var(--good); }
.dots i.skip { background: #e7b7a3; }

/* 가족 */
.member { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.member:last-child { border-bottom: 0; }
.member .av { width: 40px; height: 40px; border-radius: 50%; background: var(--moca); display: flex; align-items: center; justify-content: center; font-family: "Jua", sans-serif; }
.code { font-family: "Jua", sans-serif; font-size: 34px; letter-spacing: 6px; text-align: center; background: #fff; border: 2px dashed var(--moca); border-radius: 14px; padding: 10px; }

/* 합류 */
.join { max-width: 420px; margin: 24px auto; }
.join .hero-emoji { font-size: 72px; text-align: center; }
.join h1 { text-align: center; font-size: 30px; margin: 8px 0 20px; }

/* 토스트·모달 */
.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 50; }
.modal { position: fixed; inset: 0; background: rgba(59,49,39,.55); z-index: 40; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal .sheet { background: var(--card); border-radius: 20px; padding: 24px; width: 100%; max-width: 380px; text-align: center; }
.celebrate .big-ico { font-size: 84px; animation: pop .6s ease-out; }
@keyframes pop { 0% { transform: scale(.2) rotate(-20deg); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
.confetti { position: fixed; top: -10px; width: 10px; height: 14px; border-radius: 2px; animation: fall 1.8s linear forwards; z-index: 45; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); opacity: .2; } }

.empty { text-align: center; color: var(--ink-2); padding: 20px 10px; }
.empty .e { font-size: 40px; }
