@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css');

:root {
  --bg: #f2f4f6;
  --card: #ffffff;
  --fill: #f2f4f6;
  --fill-strong: #e5e8eb;
  --line: #e5e8eb;
  --text: #191f28;
  --text-2: #4e5968;
  --text-3: #8b95a1;
  --blue: #3182f6;
  --blue-press: #1b64da;
  --blue-weak: #e8f3ff;
  --red: #f04452;
  --red-weak: #ffeeee;
  --backdrop: rgba(0, 0, 0, 0.45);
  --m-taewon: #3182f6;
  --m-elle: #ff8a3d;
  --m-emil: #8b5cf6;
  --m-celine: #e9489b;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101013;
    --card: #1d1d22;
    --fill: #2c2c35;
    --fill-strong: #3c3c47;
    --line: #2c2c35;
    --text: #ececf1;
    --text-2: #b0b0bc;
    --text-3: #7e7e8b;
    --blue-weak: #1b2a44;
    --red-weak: #3a1d22;
    --backdrop: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: -0.01em;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
.num { font-variant-numeric: tabular-nums; }

.wrap { max-width: 480px; margin: 0 auto; padding: 0 16px calc(110px + env(safe-area-inset-bottom)); }

/* 상단 바 */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  height: 56px; margin: 0 -16px; padding: 0 16px;
  background: var(--bg);
}
.top h1 { flex: 1; margin: 0; font-size: 20px; font-weight: 700; }
.top .back { width: 36px; height: 36px; margin-left: -8px; display: grid; place-items: center; border-radius: 10px; color: var(--text); }
.top .back:active { background: var(--fill-strong); }

/* 카드 */
.card { background: var(--card); border-radius: 20px; padding: 22px 20px; margin-bottom: 12px; }
.card-title { font-size: 15px; font-weight: 600; color: var(--text-2); margin: 0 0 14px; }
.label { font-size: 14px; color: var(--text-3); }
.big { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.sub { font-size: 14px; color: var(--text-3); margin-top: 2px; }
.plus { color: var(--blue); }
.minus { color: var(--red); }

/* 아바타 */
.av {
  --c: var(--blue);
  display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--c); color: #fff; font-weight: 700; font-size: 15px;
}
.av.sm { width: 24px; height: 24px; font-size: 11px; }
.av.lg { width: 48px; height: 48px; font-size: 20px; }
.av[data-m="taewon"] { --c: var(--m-taewon); }
.av[data-m="elle"] { --c: var(--m-elle); }
.av[data-m="emil"] { --c: var(--m-emil); }
.av[data-m="celine"] { --c: var(--m-celine); }

/* 목록 행 */
.row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 0; text-align: left; }
.row + .row { border-top: 0; }
button.row { border-radius: 12px; margin: 0 -8px; padding: 12px 8px; width: calc(100% + 16px); }
button.row:active { background: var(--fill); }
.row .ico { width: 40px; height: 40px; border-radius: 50%; background: var(--fill); display: grid; place-items: center; font-size: 19px; flex: none; }
.row .mid { flex: 1; min-width: 0; }
.row .t { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { font-size: 13px; color: var(--text-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .end { text-align: right; flex: none; }
.row .end .t { font-weight: 700; }

/* 버튼 */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 56px; width: 100%; border-radius: 16px;
  background: var(--blue); color: #fff; font-size: 17px; font-weight: 600;
}
.btn:active { background: var(--blue-press); }
.btn:disabled { opacity: 0.4; }
.btn.weak { background: var(--blue-weak); color: var(--blue); }
.btn.gray { background: var(--fill); color: var(--text-2); }
.btn.danger { background: var(--red-weak); color: var(--red); }
.btn.sm { height: 36px; width: auto; padding: 0 14px; border-radius: 10px; font-size: 14px; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }
.btn-row .btn.gray, .btn-row .btn.danger { flex: 0 0 34%; }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.dock .btn { max-width: 448px; margin: 0 auto; }

/* 탭 · 세그먼트 */
.seg { display: flex; background: var(--fill); border-radius: 12px; padding: 3px; }
.seg button { flex: 1; height: 36px; border-radius: 9px; font-size: 15px; font-weight: 600; color: var(--text-3); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
.tabs { margin: 20px 0 12px; }
.seg.on-bg { background: var(--fill-strong); }

/* 칩 */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; margin: 0 -20px; padding: 0 20px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 40px; padding: 0 14px; border-radius: 20px;
  background: var(--fill); color: var(--text-2); font-size: 15px; font-weight: 500;
}
.chip.person { padding-left: 6px; }
.chip.on { background: var(--blue-weak); color: var(--blue); font-weight: 600; box-shadow: inset 0 0 0 1.5px var(--blue); }

/* 입력 */
.field { margin-top: 22px; }
.field > .label { display: block; margin-bottom: 8px; font-weight: 500; }
.input {
  width: 100%; height: 52px; padding: 0 16px; border-radius: 14px;
  border: 0; background: var(--fill); font-size: 16px; outline: none;
}
.input:focus { box-shadow: inset 0 0 0 2px var(--blue); }
.input::placeholder { color: var(--text-3); }

.amount { display: flex; align-items: center; gap: 10px; }
.amount input {
  flex: 1; min-width: 0; border: 0; outline: none; background: none;
  font-size: 34px; font-weight: 700; letter-spacing: -0.02em; padding: 4px 0;
}
.amount input::placeholder { color: var(--fill-strong); }
.cur { display: flex; background: var(--fill); border-radius: 12px; padding: 3px; flex: none; }
.cur button { width: 40px; height: 38px; border-radius: 9px; font-size: 18px; font-weight: 700; color: var(--text-3); }
.cur button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }

.split-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.split-row .name { flex: 1; font-weight: 500; }
.split-row input { width: 130px; text-align: right; height: 44px; }
.hint { font-size: 14px; color: var(--text-3); margin-top: 10px; }
.hint.bad { color: var(--red); }

/* 바텀시트 */
.backdrop {
  position: fixed; inset: 0; z-index: 50; background: var(--backdrop);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity 0.2s;
}
.backdrop.show { opacity: 1; }
.sheet {
  width: 100%; max-width: 480px; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--card); border-radius: 24px 24px 0 0;
  padding: 10px 20px calc(16px + env(safe-area-inset-bottom));
  transform: translateY(40px); transition: transform 0.22s ease-out;
}
.backdrop.show .sheet { transform: none; }
.sheet .handle { width: 40px; height: 4px; border-radius: 2px; background: var(--fill-strong); margin: 0 auto 16px; }
.sheet h2 { margin: 0 0 18px; font-size: 21px; font-weight: 700; }
.sheet .actions { position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); margin: 26px -20px 0; padding: 12px 20px calc(4px + env(safe-area-inset-bottom)); background: var(--card); }

/* 토스트 */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; transition: 0.2s;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px; border-radius: 14px; background: #333d4b; color: #fff; font-size: 15px;
  max-width: calc(100% - 32px); white-space: nowrap;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast button { color: #8fc1ff; font-weight: 600; }

.empty { text-align: center; color: var(--text-3); padding: 36px 0 30px; font-size: 15px; }
.day { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.day .d { font-size: 15px; font-weight: 600; color: var(--text-2); }
.day .sum { font-size: 13px; color: var(--text-3); }

.rate-chip { display: inline-flex; align-items: center; gap: 4px; margin-top: 14px; height: 30px; padding: 0 12px; border-radius: 15px; background: var(--fill); font-size: 13px; color: var(--text-2); font-weight: 500; }

/* 누구세요 */
.who { position: fixed; inset: 0; z-index: 70; background: var(--card); display: flex; flex-direction: column; justify-content: center; padding: 24px; }
.who h2 { font-size: 26px; margin: 0 0 6px; }
.who p { color: var(--text-3); margin: 0 0 28px; }
.who .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.who .grid button { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 0; border-radius: 20px; background: var(--fill); font-size: 17px; font-weight: 600; }
.who .grid button:active { background: var(--fill-strong); }

.hidden { display: none !important; }
