/* ============================================================
   나트랑 가족여행 대시보드 — 카카오톡 스타일 / 모바일 우선 / 다크모드
   ============================================================ */

:root {
  --kakao-yellow: #FEE500;
  --kakao-brown: #3C1E1E;
  --bg: #F5F6F8;
  --card: #FFFFFF;
  --text: #191919;
  --text-sub: #6B6B6B;
  --line: #ECECEC;
  --bubble: #FEF3B3;
  --accent: #3C1E1E;
  --danger: #E5484D;
  --ok: #2E9E5B;
  --nav-bg: #FFFFFF;
  --shadow: 0 1px 4px rgba(0,0,0,.06);
}

html[data-theme="dark"] {
  --bg: #17171C;
  --card: #26262E;
  --text: #F1F1F4;
  --text-sub: #A8A8B3;
  --line: #37373F;
  --bubble: #4A4222;
  --accent: #FEE500;
  --nav-bg: #1E1E24;
  --shadow: 0 1px 4px rgba(0,0,0,.4);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    --bg: #17171C;
    --card: #26262E;
    --text: #F1F1F4;
    --text-sub: #A8A8B3;
    --line: #37373F;
    --bubble: #4A4222;
    --accent: #FEE500;
    --nav-bg: #1E1E24;
    --shadow: 0 1px 4px rgba(0,0,0,.4);
  }
}

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

html { font-size: 17px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  max-width: 640px;
  margin: 0 auto;
}

/* ---------- 헤더 ---------- */
header {
  position: sticky; top: 0; z-index: 50;
  background: var(--kakao-yellow);
  color: var(--kakao-brown);
  padding: 14px 18px calc(14px);
  padding-top: max(14px, env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between;
  border-radius: 0 0 18px 18px;
  box-shadow: var(--shadow);
}
header h1 { font-size: 1.25rem; font-weight: 800; }
header .sub { font-size: .85rem; font-weight: 600; opacity: .75; }
#themeBtn {
  border: none; background: rgba(60,30,30,.12); color: var(--kakao-brown);
  font-size: 1.3rem; width: 46px; height: 46px; border-radius: 50%; cursor: pointer;
}

/* ---------- 공통 ---------- */
main { padding: 16px 14px 8px; }
section.tab { display: none; }
section.tab.active { display: block; animation: fadein .18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none;} }

.card {
  background: var(--card); border-radius: 18px; padding: 16px;
  margin-bottom: 14px; box-shadow: var(--shadow);
}
.card h2 { font-size: 1.05rem; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.card h2 .badge { margin-left: auto; }

.bubble {
  background: var(--bubble); border-radius: 4px 18px 18px 18px;
  padding: 12px 14px; font-size: .95rem; margin-bottom: 12px;
}

.badge {
  display: inline-block; font-size: .74rem; font-weight: 700;
  padding: 3px 10px; border-radius: 999px;
  background: var(--kakao-yellow); color: var(--kakao-brown);
}
.badge.gray { background: var(--line); color: var(--text-sub); }
.badge.red { background: var(--danger); color: #fff; }
.badge.green { background: var(--ok); color: #fff; }

.row { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.row:last-child { border-bottom: none; }
.row .k { color: var(--text-sub); flex-shrink: 0; }
.row .v { font-weight: 600; text-align: right; word-break: break-all; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px; margin-top: 10px;
  border: none; border-radius: 14px; cursor: pointer;
  font-size: 1rem; font-weight: 700; text-decoration: none;
  background: var(--kakao-yellow); color: var(--kakao-brown);
}
.btn.sub { background: var(--line); color: var(--text); }
.btn.danger { background: var(--danger); color: #fff; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

.muted { color: var(--text-sub); font-size: .85rem; }
.todo { color: var(--danger); font-weight: 700; font-size: .85rem; }

/* ---------- 체크리스트 ---------- */
.chk {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid var(--line);
  cursor: pointer; user-select: none;
}
.chk:last-child { border-bottom: none; }
.chk input { width: 26px; height: 26px; accent-color: #F5A623; flex-shrink: 0; margin-top: 2px; cursor: pointer; }
.chk.done .t { text-decoration: line-through; color: var(--text-sub); }
.chk .t { font-weight: 600; }
.chk .n { font-size: .84rem; color: var(--text-sub); margin-top: 2px; }
.chk .time { font-weight: 800; color: var(--accent); font-size: .9rem; margin-right: 2px; }

/* ---------- 일정 타임라인 ---------- */
.day-head {
  display: flex; align-items: baseline; gap: 10px;
  margin: 20px 4px 10px; font-weight: 800; font-size: 1.05rem;
}
.day-head:first-child { margin-top: 4px; }
.day-head .d-label { font-size: .82rem; color: var(--text-sub); font-weight: 600; }
.day-head.today-mark::after { content: "오늘"; font-size: .72rem; background: var(--danger); color: #fff; padding: 2px 8px; border-radius: 999px; }

/* ---------- 사진첩 ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 6px; }
.photo-grid img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 10px; cursor: pointer; background: var(--line);
}
#lightbox {
  position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.93);
  display: none; flex-direction: column; justify-content: center;
}
#lightbox.open { display: flex; }
#lightbox img { max-width: 100%; max-height: 78vh; object-fit: contain; }
#lb-meta { color: #fff; text-align: center; padding: 14px; font-size: .95rem; }
#lb-meta .loc { font-weight: 700; }
#lb-close {
  position: absolute; top: max(14px, env(safe-area-inset-top)); right: 14px;
  width: 46px; height: 46px; border-radius: 50%; border: none;
  background: rgba(255,255,255,.15); color: #fff; font-size: 1.4rem; cursor: pointer;
}

/* ---------- 계산기 ---------- */
.calc input[type="text"], .calc input[type="number"], #memoInput, #pinInput {
  width: 100%; min-height: 54px; font-size: 1.25rem; font-weight: 700;
  padding: 10px 14px; border: 2px solid var(--line); border-radius: 14px;
  background: var(--bg); color: var(--text); outline: none;
}
.calc input:focus { border-color: var(--kakao-yellow); }
.calc-result {
  font-size: 1.7rem; font-weight: 800; text-align: center;
  padding: 16px 0 6px; color: var(--accent);
}
.chip-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.chip {
  flex: 1; min-height: 46px; border: none; border-radius: 12px;
  background: var(--line); color: var(--text); font-weight: 700; font-size: .92rem; cursor: pointer;
}
.rate-line { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: .85rem; color: var(--text-sub); flex-wrap: wrap; }
.rate-line input { width: 110px; min-height: 40px !important; font-size: 1rem !important; }

/* ---------- 메모 ---------- */
.memo-item {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--bubble); border-radius: 4px 16px 16px 16px;
  padding: 12px 14px; margin-bottom: 10px;
}
.memo-item .m-text { flex: 1; white-space: pre-wrap; word-break: break-word; }
.memo-item .m-date { display: block; font-size: .72rem; color: var(--text-sub); margin-top: 4px; }
.memo-item button { border: none; background: none; font-size: 1.1rem; cursor: pointer; color: var(--text-sub); }
#memoInput { font-size: 1rem; font-weight: 500; min-height: 74px; resize: vertical; font-family: inherit; }

/* ---------- 하단 탭바 ---------- */
nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 640px; z-index: 100;
  background: var(--nav-bg); border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom);
}
nav button {
  flex: 1; border: none; background: none; cursor: pointer;
  padding: 9px 0 7px; color: var(--text-sub);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: .72rem; font-weight: 700;
}
nav button .ico { font-size: 1.45rem; }
nav button.active { color: var(--accent); }
nav button.active .ico { transform: scale(1.12); }

/* ---------- 더보기 시트 ---------- */
#moreSheet {
  position: fixed; inset: 0; z-index: 150; background: rgba(0,0,0,.45);
  display: none; align-items: flex-end;
}
#moreSheet.open { display: flex; }
#moreSheet .sheet {
  background: var(--card); width: 100%; max-width: 640px; margin: 0 auto;
  border-radius: 22px 22px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
}
#moreSheet .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
#moreSheet .grid button {
  border: none; border-radius: 16px; background: var(--bg); color: var(--text);
  min-height: 84px; font-size: .9rem; font-weight: 700; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center;
}
#moreSheet .grid button .ico { font-size: 1.7rem; }
.sheet-bar { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }

/* ---------- PIN 게이트 ---------- */
#pinGate {
  position: fixed; inset: 0; z-index: 300; background: var(--kakao-yellow);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 24px;
}
#pinGate.hidden { display: none; }
#pinGate h2 { color: var(--kakao-brown); font-size: 1.3rem; }
#pinGate .dots { display: flex; gap: 16px; }
#pinGate .dot { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--kakao-brown); }
#pinGate .dot.fill { background: var(--kakao-brown); }
#pinPad { display: grid; grid-template-columns: repeat(3, 76px); gap: 12px; }
#pinPad button {
  width: 76px; height: 64px; font-size: 1.5rem; font-weight: 800;
  border: none; border-radius: 16px; background: rgba(255,255,255,.75);
  color: var(--kakao-brown); cursor: pointer;
}
#pinPad button:active { background: #fff; }
#pinMsg { color: var(--danger); font-weight: 700; min-height: 1.4em; }

/* ---------- 토스트 ---------- */
#toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: rgba(25,25,25,.88); color: #fff; padding: 12px 20px;
  border-radius: 999px; font-size: .9rem; z-index: 400;
  opacity: 0; pointer-events: none; transition: opacity .25s; white-space: nowrap;
}
#toast.show { opacity: 1; }

/* ---------- 홈 전용 ---------- */
.hero {
  background: var(--card); border-radius: 18px; padding: 18px 16px;
  margin-bottom: 14px; box-shadow: var(--shadow); text-align: center;
}
.hero .dday { font-size: 1.5rem; font-weight: 800; margin: 4px 0; }
.hero .date-line { color: var(--text-sub); font-size: .9rem; }
.hero select {
  margin-top: 10px; min-height: 42px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: .9rem; padding: 0 10px; font-weight: 600;
}
.quick-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.quick-row button {
  border: none; border-radius: 16px; background: var(--card); box-shadow: var(--shadow);
  min-height: 76px; cursor: pointer; color: var(--text);
  display: flex; flex-direction: column; gap: 4px; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700;
}
.quick-row button .ico { font-size: 1.5rem; }

.progress-wrap { background: var(--line); border-radius: 999px; height: 10px; overflow: hidden; margin-top: 8px; }
.progress-bar { height: 100%; background: var(--kakao-yellow); border-radius: 999px; transition: width .3s; }

@media (min-width: 480px) {
  html { font-size: 18px; }
}
