/* ===========================================================
   트립푸 — 여행 계획 & 예산 가계부
   디자인 시스템: Supabase 계열 — 화이트 베이스 / 그린 브랜드 / 보더 기반 카드 /
   Inter + 시스템 폰트 / 촘촘한 4px 그리드 / 낮은 채도의 뉴트럴
   =========================================================== */

:root {
  /* ── 표면 (밝을수록 "떠 있는" 느낌) ── */
  --bg-deep: #EDEDEF;   /* 가장 깊음 — 바깥 프레임, 트랙, 태그 배경 */
  --bg: #FAFAFA;        /* 앱 배경 */
  --surface-2: #F4F4F5; /* 카드 위에 얹히는 인풋/세그먼트 배경 */
  --surface: #FFFFFF;   /* 카드, 버튼(ghost), 아이콘 버튼 */
  --surface-3: #F0F0F1; /* hover/active */

  --line: #E4E4E7;      /* 기본 보더 */
  --line-soft: #ECECEE;

  /* ── 텍스트 ── */
  --ink: #18181B;
  --ink-2: #52525B;
  --ink-3: #94949C;

  /* ── 브랜드 (Supabase Green) ── */
  --primary: #3ECF8E;
  --primary-deep: #249966;
  --primary-soft: rgba(62, 207, 142, .12);
  --on-brand: #062014;   /* 그린 버튼 위 텍스트 */

  /* ── 상태 색 ── */
  --danger: #E5484D;
  --danger-soft: rgba(229, 72, 77, .10);
  --mint: #249966;
  --mint-soft: rgba(62, 207, 142, .12);
  --lav: #7B67D9;
  --lav-soft: rgba(123, 103, 217, .10);
  --sun: #B77B21;
  --sun-soft: rgba(217, 145, 33, .12);
  --sky: #2F6FE0;
  --sky-soft: rgba(47, 111, 224, .10);

  /* ── 4px 그리드 기반 라운드 ── */
  --r-lg: 12px;
  --r-md: 8px;
  --r-sm: 6px;
  --shadow: 0 1px 3px rgba(20, 20, 25, .06);
  --shadow-sm: 0 1px 2px rgba(20, 20, 25, .05);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
          "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

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

html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg-deep);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { min-height: 100vh; }

.phone {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  border-left: 1px solid var(--line-soft);
  border-right: 1px solid var(--line-soft);
  position: relative;
  overflow-x: hidden;
}

.app { padding: 0 16px 120px; }

/* ---------- 공통 타이포 ---------- */
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea {
  font-family: inherit; font-size: 15px; color: var(--ink);
}
a { color: inherit; }

.muted { color: var(--ink-3); }
.soft { color: var(--ink-2); }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- 헤더 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 0 12px;
  background: linear-gradient(var(--bg) 70%, rgba(250,250,250,0));
  backdrop-filter: blur(8px);
}
.topbar h1 { font-size: 19px; font-weight: 600; }
.topbar .sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; font-weight: 500; }

.icon-btn {
  width: 36px; height: 36px; flex: none;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  display: grid; place-items: center;
  font-size: 15px;
  transition: background .12s ease, border-color .12s ease;
}
.icon-btn:active { background: var(--surface-3); }

/* ---------- 카드 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card.tight { padding: 13px 15px; }

/* ---------- 홈: 여행 카드 ---------- */
.hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.hero .mascot { font-size: 32px; line-height: 1; }
.hero h2 { font-size: 17px; margin-top: 10px; font-weight: 600; }
.hero p { font-size: 13px; color: var(--ink-2); margin-top: 6px; line-height: 1.6; }
.hero::before {
  content: ""; position: absolute; left: 0; top: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--primary), transparent 70%);
}

.trip-card {
  display: block; width: 100%; text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 15px 16px;
  box-shadow: var(--shadow);
  transition: border-color .14s ease, background .14s ease;
}
.trip-card:active { background: var(--surface-3); }
.trip-card:hover { border-color: #D4D4D8; }
.trip-card .emoji { font-size: 26px; line-height: 1; }
.trip-card .title { font-size: 16px; font-weight: 600; }
.trip-card .meta { font-size: 12px; color: var(--ink-3); margin-top: 3px; font-weight: 500; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px;
  background: var(--sky-soft); color: var(--sky);
  border: 1px solid transparent;
}
.badge::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; flex: none;
}
.badge.dom { background: var(--mint-soft); color: var(--mint); }
.badge.dday { background: var(--primary-soft); color: var(--primary-deep); }
.badge.done { background: var(--surface-2); color: var(--ink-3); }
.badge.done::before { display: none; }

/* ---------- 진행 바 ---------- */
.bar {
  height: 6px; border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.bar > i {
  display: block; height: 100%; border-radius: 999px;
  background: var(--primary);
  transition: width .4s cubic-bezier(.2,.8,.3,1);
}
.bar.over > i { background: var(--danger); }
.bar.mini { height: 5px; }

/* ---------- 요약: 스탯 그리드 ---------- */
.summary {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 4px;
}
.stat-grid {
  display: grid; grid-template-columns: 1fr 1fr;
}
.stat-tile {
  padding: 14px 16px;
  border-right: 1px solid var(--line);
}
.stat-tile:last-child { border-right: none; }
.summary .label { font-size: 11px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .03em; }
.summary .big { font-size: 22px; font-weight: 600; letter-spacing: -.01em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.summary .bar-row { padding: 12px 16px 14px; border-top: 1px solid var(--line); }

/* ---------- 탭 ---------- */
.tabs {
  display: flex; gap: 2px;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 3px;
  margin: 14px 0;
  position: sticky; top: 58px; z-index: 20;
}
.tabs button {
  flex: 1; padding: 8px 4px;
  border-radius: var(--r-sm);
  font-size: 12.5px; font-weight: 500; color: var(--ink-3);
  transition: all .14s ease;
}
.tabs button.on {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

/* ---------- 카테고리 행 ---------- */
.cat {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0;
}
.cat + .cat { border-top: 1px solid var(--line); }
.cat .ico {
  width: 34px; height: 34px; flex: none;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  font-size: 16px;
}
.cat .name { font-size: 14px; font-weight: 500; color: var(--ink); }
.cat .amt { font-size: 13px; font-weight: 600; text-align: right; white-space: nowrap; flex: none; font-variant-numeric: tabular-nums; }
.amt-sub {
  display: block; margin-top: 2px;
  font-size: 10.5px; font-weight: 500; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.cat .sub { font-size: 11.5px; color: var(--ink-3); font-weight: 500; margin-top: 2px; }

/* ---------- 체크 줄 ---------- */
.check-row {
  display: flex; align-items: center; gap: 11px;
  width: 100%; text-align: left;
  padding: 12px 0 2px;
  margin-top: 11px;
  border-top: 1px solid var(--line);
}
.check-row .box {
  width: 18px; height: 18px; flex: none;
  border-radius: 5px;
  border: 1.5px solid var(--ink-3);
  background: var(--surface);
  display: grid; place-items: center;
  font-size: 11px; color: var(--on-brand); font-weight: 700;
  transition: all .14s ease;
}
.check-row .box.on { background: var(--primary); border-color: var(--primary); }
.check-row .grow { display: block; }
.check-row .t { display: block; font-size: 13px; font-weight: 500; color: var(--ink); }
.check-row .s { display: block; font-size: 11px; color: var(--ink-3); font-weight: 500; margin-top: 3px; line-height: 1.5; }

.tag {
  display: inline-block;
  font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--ink-3);
  border: 1px solid var(--line);
  margin-left: 5px; vertical-align: middle;
}

.add-line {
  display: block; width: 100%; text-align: left;
  padding: 12px 0 10px;
  border-top: 1px solid var(--line);
  font-size: 12.5px; font-weight: 600; color: var(--primary-deep);
}
.card > .add-line:first-child { border-top: none; padding: 13px 0; }

/* ---------- 입력 ---------- */
.field { margin-bottom: 13px; }
.field > label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--ink-2); margin-bottom: 6px; padding-left: 1px;
}
.input, select.input, textarea.input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 11px 13px;
  font-size: 15px; font-weight: 500; color: var(--ink);
  outline: none;
  transition: border-color .14s, box-shadow .14s, background .14s;
  -webkit-appearance: none; appearance: none;
}
.input::placeholder { color: var(--ink-3); }
.input:focus { border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.input { resize: vertical; min-height: 74px; line-height: 1.5; }
select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394949C' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
  padding-right: 34px;
}
.input.amount { font-variant-numeric: tabular-nums; font-weight: 600; font-family: var(--mono); }

.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1; padding: 11px 6px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  font-size: 13.5px; font-weight: 500; color: var(--ink-3);
  border: 1px solid var(--line);
  transition: all .14s;
}
.seg button.on {
  background: var(--primary-soft); color: var(--primary-deep);
  border-color: var(--primary);
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 7px 11px; border-radius: 999px;
  background: var(--surface-2);
  font-size: 12.5px; font-weight: 500; color: var(--ink-2);
  border: 1px solid var(--line);
  transition: all .14s;
}
.chip.on { border-color: currentColor; }
.chip .dc-sub { font-weight: 500; opacity: .6; font-size: 11px; }

/* ---------- 버튼 ---------- */
.btn {
  display: block; width: 100%;
  padding: 13px; border-radius: var(--r-md);
  font-size: 14px; font-weight: 600;
  background: var(--primary); color: var(--on-brand);
  transition: background .12s ease, transform .08s ease;
}
.btn:active { transform: scale(.985); }
.btn:hover { background: var(--primary-deep); color: #fff; }
.btn.ghost {
  background: var(--surface); color: var(--ink-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.btn.ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn.soft { background: var(--primary-soft); color: var(--primary-deep); }
.btn.soft:hover { background: var(--primary-soft); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: 10px; font-size: 13px; border-radius: var(--r-sm); }

.fab {
  position: fixed; bottom: 22px; z-index: 40;
  left: 50%; transform: translateX(-50%);
  width: min(448px, calc(100vw - 32px));
  padding: 14px; border-radius: var(--r-md);
  background: var(--primary); color: var(--on-brand);
  font-size: 14px; font-weight: 600;
  box-shadow: 0 8px 20px rgba(20,20,25,.16), 0 0 0 1px rgba(62,207,142,.25);
}
.fab:active { transform: translateX(-50%) scale(.98); }

/* ---------- 리스트 아이템 ---------- */
.item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  padding: 12px 14px;
  width: 100%; text-align: left;
  transition: background .12s ease, border-color .12s ease;
}
.item:hover { border-color: #D4D4D8; }
.item .ico {
  width: 34px; height: 34px; flex: none;
  border-radius: var(--r-sm); display: grid; place-items: center; font-size: 16px;
  position: relative;
}
.item .t { font-size: 14px; font-weight: 500; color: var(--ink); }
.item .s { font-size: 11.5px; color: var(--ink-3); font-weight: 500; margin-top: 2px; }
.item .r { font-size: 13.5px; font-weight: 600; flex: none; text-align: right; font-variant-numeric: tabular-nums; }

/* 목록 아이콘 위의 동선 번호 */
.pin-no {
  position: absolute; top: -5px; right: -5px;
  min-width: 16px; height: 16px; padding: 0 3px;
  border-radius: 999px;
  background: var(--primary); color: var(--on-brand);
  font-size: 9.5px; font-weight: 700;
  display: grid; place-items: center;
  border: 2px solid var(--surface);
}

/* 순서 바꾸기 ▲▼ */
.reorder { display: flex; flex-direction: column; gap: 2px; flex: none; }
.reorder button {
  width: 22px; height: 18px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-3); font-size: 8px;
  display: grid; place-items: center;
  transition: all .12s;
}
.reorder button:active { background: var(--primary-soft); color: var(--primary-deep); }
.reorder button:disabled { opacity: .3; }

/* ---------- 지도 ---------- */
.map-wrap {
  position: relative;
  height: 300px;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.map-wrap > .map { width: 100%; height: 100%; }
.map-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 24px; text-align: center;
  background: var(--surface-2);
}
.map-empty .e { font-size: 30px; opacity: .8; }
.map-empty p { font-size: 12.5px; color: var(--ink-2); line-height: 1.6; font-weight: 500; }

.search-row { display: flex; gap: 8px; margin-bottom: 12px; }
.search-row .input { flex: 1; }
.search-row button {
  flex: none; padding: 0 16px; border-radius: var(--r-md);
  background: var(--primary); color: var(--on-brand); font-weight: 600; font-size: 14px;
}
.result-list { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.result-list button {
  text-align: left; padding: 10px 12px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 13px; font-weight: 500; color: var(--ink);
}
.result-list button span { display: block; font-size: 11.5px; color: var(--ink-3); margin-top: 2px; font-weight: 500; }

/* ---------- 시트(모달) ---------- */
.sheet-mask {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(15, 15, 18, .5);
  backdrop-filter: blur(2px);
  animation: fade .2s ease;
}
.sheet {
  position: fixed; z-index: 91;
  left: 50%; transform: translateX(-50%);
  bottom: 0; width: 100%; max-width: 480px;
  max-height: 92vh; overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  padding: 10px 16px calc(24px + env(safe-area-inset-bottom));
  animation: rise .26s cubic-bezier(.2,.9,.3,1);
  box-shadow: 0 -8px 30px rgba(20,20,25,.12);
}
.sheet .handle {
  width: 36px; height: 4px; border-radius: 99px;
  background: var(--line); margin: 6px auto 14px;
}
.sheet h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
@keyframes rise { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

/* ---------- 토스트 (테마와 무관하게 늘 다크 — 어디서든 눈에 띄도록) ---------- */
.toast-root {
  position: fixed; z-index: 200; left: 50%; bottom: 92px;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: #18181B; color: #FAFAFA;
  padding: 10px 16px; border-radius: var(--r-md);
  font-size: 13px; font-weight: 500;
  animation: fade .2s ease;
  box-shadow: 0 8px 20px rgba(20,20,25,.28);
}

/* ---------- 빈 상태 ---------- */
.empty {
  text-align: center; padding: 36px 20px;
}
.empty .e { font-size: 36px; opacity: .85; }
.empty h4 { font-size: 14px; margin-top: 12px; font-weight: 600; }
.empty p { font-size: 12.5px; color: var(--ink-3); margin-top: 6px; line-height: 1.6; font-weight: 500; }

/* ---------- 섹션 타이틀 ---------- */
.sec-title {
  font-size: 12px; font-weight: 600; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .04em;
  padding-left: 1px; margin: 20px 0 9px;
  display: flex; align-items: center; justify-content: space-between;
}
.sec-title button { font-size: 12px; font-weight: 600; color: var(--primary-deep); text-transform: none; letter-spacing: 0; }

/* ---------- 결산 ---------- */
.verdict {
  border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 20px; text-align: center;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.verdict.over { border-color: rgba(229,72,77,.35); }
.verdict .e { font-size: 34px; }
.verdict h3 { font-size: 16px; margin-top: 10px; font-weight: 600; }
.verdict p { font-size: 12.5px; color: var(--ink-2); margin-top: 6px; font-weight: 500; line-height: 1.6; }

.daybar { display: flex; align-items: flex-end; gap: 5px; height: 90px; }
.daybar > div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.daybar i {
  display: block; border-radius: 3px 3px 2px 2px;
  background: var(--primary); min-height: 3px;
}
.daybar .lbl { font-size: 9px; color: var(--ink-3); text-align: center; margin-top: 5px; font-weight: 500; }

hr.sep { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
