/* 후추 케어 원장 — 모바일 우선.
   결: 사육장의 이끼색 어둠 + 후추 몸빛의 호박색 포인트. */
:root {
  --bg: #12160f;
  --bg-soft: #1a2016;
  --card: #1e2519;
  --line: #2e3826;
  --ink: #eef2e6;
  --ink-dim: #9aa891;
  --ink-faint: #6d7a66;
  --moss: #7fae4e;
  --amber: #e8a13c;
  --amber-soft: #3a2c14;
  --danger: #d9705a;
  --radius: 16px;
  --pad: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

body {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 var(--pad) calc(24px + env(safe-area-inset-bottom));
}

/* ── 오프라인 배너 ── */
.offline {
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 13px;
  text-align: center;
  padding: 8px 12px;
  border-radius: 10px;
  margin-top: 10px;
}

/* ── 프로필 ── */
.profile {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 2px 12px;
}
.avatar {
  width: 42px; height: 42px;
  flex: none;
  display: grid; place-items: center;
  font-size: 24px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 13px;
}
.who h1 { margin: 0; font-size: 19px; letter-spacing: -.01em; }
.who p { margin: 1px 0 0; font-size: 12px; color: var(--ink-dim); }

/* ── 히어로: D-day ── */
.hero {
  background: linear-gradient(160deg, #24301b, var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 15px;
  text-align: center;
}
.hero.warn { border-color: #6b5220; background: linear-gradient(160deg, #34290f, var(--card)); }
.hero.over { border-color: #6d3b2f; background: linear-gradient(160deg, #35201a, var(--card)); }

.hero-label { font-size: 12px; color: var(--ink-dim); letter-spacing: .04em; }
.hero-value {
  font-size: 42px;
  font-weight: 750;
  line-height: 1.1;
  margin: 2px 0 3px;
  letter-spacing: -.02em;
  color: var(--moss);
  font-variant-numeric: tabular-nums;
}
.hero.warn .hero-value { color: var(--amber); }
.hero.over .hero-value { color: var(--danger); }
.hero-value .unit { font-size: 17px; font-weight: 600; margin-left: 2px; }
.hero-sub { font-size: 12.5px; color: var(--ink-dim); }

/* ── 3-up 요약 ── */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 9px 6px 8px;
  text-align: center;
  min-width: 0;
}
.stat-label { display: block; font-size: 10.5px; color: var(--ink-faint); }
.stat strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
  margin: 2px 0 1px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat-foot {
  display: block;
  font-size: 10.5px;
  color: var(--ink-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-foot.up { color: var(--moss); }
.stat-foot.down { color: var(--danger); }

/* ── 빠른 기록 ── */
.quick {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.qbtn {
  appearance: none;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 4px 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  transition: transform .08s, border-color .15s, background .15s;
}
.qbtn span { font-size: 21px; line-height: 1; }
.qbtn:active { transform: scale(.96); border-color: var(--moss); background: #232c1c; }

/* ── 카드 공통 ── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px 10px;
  margin-top: 12px;
}
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}
.card-head h2 { margin: 0; font-size: 13.5px; font-weight: 650; color: var(--ink); }
.card-head span { font-size: 11px; color: var(--ink-faint); }

/* ── 스파크라인 ── */
.sparkcard svg { display: block; width: 100%; height: 62px; overflow: visible; }

/* ── 타임라인 ── */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  align-items: flex-start;
}
.timeline li:first-child { border-top: 0; }
.timeline li.empty {
  display: block;
  color: var(--ink-faint);
  font-size: 13px;
  text-align: center;
  padding: 20px 0;
  border: 0;
}
.tl-icon { font-size: 17px; line-height: 1.3; flex: none; width: 22px; text-align: center; }
.tl-main { flex: 1; min-width: 0; }
.tl-top { display: flex; gap: 6px; align-items: baseline; }
.tl-type { font-size: 13.5px; font-weight: 650; }
.tl-val { font-size: 13px; color: var(--amber); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-memo { font-size: 12px; color: var(--ink-dim); margin-top: 1px; word-break: break-word; }
.tl-when { font-size: 11px; color: var(--ink-faint); flex: none; text-align: right; padding-top: 2px; }

footer {
  text-align: center;
  font-size: 11px;
  color: var(--ink-faint);
  padding: 18px 0 4px;
}
footer code { background: var(--bg-soft); padding: 1px 5px; border-radius: 5px; font-size: 10.5px; }

/* ── 시트 ── */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(2px);
  z-index: 20;
}
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 21;
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  animation: rise .18s ease-out;
}
@keyframes rise { from { transform: translateY(18px); opacity: .4; } }
.sheet-grip {
  width: 38px; height: 4px;
  background: var(--line);
  border-radius: 2px;
  margin: 0 auto 10px;
}
.sheet h3 { margin: 0 0 10px; font-size: 16px; }

.field { margin-bottom: 10px; }
.field label { display: block; font-size: 11.5px; color: var(--ink-dim); margin-bottom: 4px; }
.field input, .field textarea {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* iOS 자동 확대 방지 */
  padding: 10px 12px;
}
.field textarea { resize: vertical; min-height: 62px; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--moss); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  appearance: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  padding: 8px 14px;
  cursor: pointer;
}
.chip:active { border-color: var(--amber); background: var(--amber-soft); }

.sheet-hint { font-size: 11.5px; color: var(--ink-faint); margin: 0 0 10px; }
.sheet-err { color: var(--danger); font-size: 12.5px; margin: 0 0 8px; }

.sheet-actions { display: flex; gap: 8px; margin-top: 4px; }
.btn {
  flex: 1;
  appearance: none;
  border-radius: 12px;
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  padding: 12px;
  cursor: pointer;
  border: 1px solid var(--line);
}
.btn.ghost { background: transparent; color: var(--ink-dim); flex: 0 0 34%; }
.btn.primary { background: var(--moss); border-color: var(--moss); color: #10160c; }
.btn:disabled { opacity: .55; }

/* ── 토스트 ── */
.toast {
  position: fixed;
  left: 50%; bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 30;
  background: var(--moss);
  color: #10160c;
  font-size: 13.5px;
  font-weight: 650;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
  animation: rise .18s ease-out;
  max-width: 88vw;
  text-align: center;
}
.toast.bad { background: var(--danger); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
