:root {
  --bg: #f7f5f1;
  --card: #ffffff;
  --card2: #fbfaf8;
  --text: #2c2a28;
  --muted: #857f78;
  --line: #e6e1da;
  --accent: #e08a6b;
  --accent-soft: #fdf0ea;
  --blue: #5b8def;
  --green: #4cae7a;
  --amber: #d99b3d;
  --red: #d8604f;
  --pink: #e6779b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(40, 34, 28, .06), 0 4px 14px rgba(40, 34, 28, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c;
    --card: #1e2127;
    --card2: #242830;
    --text: #e8e6e3;
    --muted: #9aa0a8;
    --line: #2e333c;
    --accent: #e8977a;
    --accent-soft: #33261f;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  padding-bottom: calc(66px + env(safe-area-inset-bottom));
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }

/* ── 헤더 ───────────────────────────────── */
header.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px calc(12px) 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 10px;
}
header.top h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: -.2px; }
header.top .sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
header.top .spacer { flex: 1; }
.who-chip {
  font-size: 12px; padding: 5px 11px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
  cursor: pointer;
}

/* ── 레이아웃 ───────────────────────────── */
main { max-width: 720px; margin: 0 auto; padding: 14px 14px 28px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 12px;
}
.card > h2 {
  font-size: 13px; text-transform: none; letter-spacing: -.1px;
  margin: 0 0 10px; color: var(--muted); font-weight: 700;
  display: flex; align-items: center; gap: 6px;
}
.card > h2 .count {
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 700;
}
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.right { text-align: right; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mb8 { margin-bottom: 8px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ── 히어로 (아이 정보) ─────────────────── */
.hero {
  background: linear-gradient(135deg, var(--accent) 0%, var(--pink) 100%);
  color: #fff; border: none;
}
.hero .name { font-size: 20px; font-weight: 800; letter-spacing: -.3px; }
.hero .age { opacity: .92; font-size: 13px; margin-top: 2px; }
.hero .stats { display: flex; gap: 18px; margin-top: 12px; }
.hero .stat b { display: block; font-size: 17px; font-weight: 700; }
.hero .stat span { font-size: 11px; opacity: .85; }

/* ── 리스트 아이템 ──────────────────────── */
.item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: none; padding-bottom: 0; }
.item:first-child { padding-top: 0; }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 600; letter-spacing: -.2px; }
.item .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.item.done .title { text-decoration: line-through; color: var(--muted); }

/* ── 배지 ──────────────────────────────── */
.badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.badge.out { background: #fbe3df; color: #a83b2c; }
.badge.urgent { background: #fdeadf; color: #b8632a; }
.badge.soon { background: #fdf4dc; color: #8a6a1d; }
.badge.ok { background: #e4f3ea; color: #2f7350; }
.badge.unknown, .badge.grey, .badge.unset { background: var(--card2); color: var(--muted); }
.badge.expired { background: #fbe3df; color: #a83b2c; }
.badge.blue { background: #e3ecfd; color: #2f5bb7; }
.badge.pink { background: #fce7ef; color: #b4426a; }
@media (prefers-color-scheme: dark) {
  .badge.out, .badge.expired { background: #3d221e; color: #f0a394; }
  .badge.urgent { background: #3a2a1d; color: #eeae7f; }
  .badge.soon { background: #35301d; color: #ddc078; }
  .badge.ok { background: #1e3329; color: #7fd2a5; }
  .badge.blue { background: #1f2b42; color: #93b6f5; }
  .badge.pink { background: #3a222c; color: #eea1bd; }
}

/* ── 버튼 ──────────────────────────────── */
button {
  border: 1px solid var(--line); background: var(--card2); color: var(--text);
  border-radius: 10px; padding: 9px 13px; cursor: pointer;
  font-size: 14px; font-weight: 600; transition: filter .12s, transform .06s;
}
button:active { transform: scale(.97); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.ghost { background: transparent; }
button.sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
button.icon { padding: 6px 9px; font-size: 13px; }
button.danger { color: var(--red); border-color: transparent; background: transparent; }
button:disabled { opacity: .5; cursor: default; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── 폼 ────────────────────────────────── */
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card2);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ── 탭바 ──────────────────────────────── */
nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: color-mix(in srgb, var(--card) 94%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs button {
  flex: 1; min-width: 0; border: none; background: none; border-radius: 0;
  padding: 8px 1px 7px; font-size: 9.5px; font-weight: 600; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  white-space: nowrap; letter-spacing: -.3px;
}
nav.tabs button .ic { font-size: 18px; line-height: 1; }
nav.tabs button.on { color: var(--accent); }
nav.tabs button .dot {
  position: absolute; transform: translate(14px, -4px);
  width: 7px; height: 7px; border-radius: 50%; background: var(--red);
}

/* ── 모달 ──────────────────────────────── */
.modal-bg {
  position: fixed; inset: 0; background: rgba(20,16,12,.45); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--card); width: 100%; max-width: 560px;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
  animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(24px); opacity: .6 } to { transform: none; opacity: 1 } }
.modal h3 { margin: 0 0 14px; font-size: 17px; }
@media (min-width: 640px) {
  .modal-bg { align-items: center; }
  .modal { border-radius: 18px; }
}

/* ── 주간 식단표 ───────────────────────── */
.week { display: grid; grid-template-columns: 46px 1fr; gap: 6px; }
.week .day { font-size: 12px; color: var(--muted); padding-top: 9px; font-weight: 600; }
.week .day.today { color: var(--accent); font-weight: 800; }
.week .slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; padding: 4px 0; }
.slot {
  background: var(--card2); border: 1px dashed var(--line); border-radius: 9px;
  min-height: 44px; padding: 5px 6px; font-size: 11px; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px; overflow: hidden;
}
.slot.filled { border-style: solid; background: var(--accent-soft); border-color: transparent; }
.slot .sl { font-size: 9px; color: var(--muted); font-weight: 700; }
.slot .dn { font-weight: 600; line-height: 1.25; word-break: keep-all; }
.slot .rx { font-size: 10px; }

/* ── 차트 ──────────────────────────────── */
.chart { width: 100%; height: 180px; }
.chart line.grid { stroke: var(--line); stroke-width: 1; }
.chart path.ln { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart text { font-size: 9px; fill: var(--muted); }

/* ── 기타 ──────────────────────────────── */
.empty { text-align: center; color: var(--muted); padding: 22px 10px; font-size: 13px; }
.seg { display: flex; background: var(--card2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: none; background: none; padding: 7px; font-size: 13px; border-radius: 8px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: #2c2a28; color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 13px; z-index: 80; box-shadow: var(--shadow); max-width: 90vw;
}
.login-wrap { max-width: 380px; margin: 12vh auto; padding: 0 20px; }
.login-wrap h1 { font-size: 22px; text-align: center; margin-bottom: 6px; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.pinpad button { padding: 16px 0; font-size: 20px; font-weight: 600; }
.pindots { display: flex; gap: 10px; justify-content: center; margin: 18px 0 6px; }
.pindots i { width: 12px; height: 12px; border-radius: 50%; background: var(--line); display: block; }
.pindots i.on { background: var(--accent); }
.timeline .item { border-bottom: none; padding: 6px 0; align-items: flex-start; }
.timeline .when { font-size: 11px; color: var(--muted); width: 82px; flex: none; padding-top: 2px; }
