/* ============================================================================
   style.css - 쿨타임 전체 디자인
   - 다크모드 우선 + 라이트모드(설정으로 전환)
   - 모바일 세로화면 우선
   - 색맹 배려: 색 외에 'D-숫자', '위치(정렬)', '글자 라벨'로도 위급도 구분
   ============================================================================ */

/* ---- 색/간격 변수 (다크 기본) ---- */
:root {
  color-scheme: dark;
  --bg: #14161b;
  --surface: #1c1f26;
  --surface-2: #232730;
  --text: #e9edf2;
  --muted: #9aa3ad;
  --line: #2a2e36;
  --accent: #5b8def;
  --green: #52b788;
  --yellow: #f4c042;
  --red: #ff6b6b;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --maxw: 540px;
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --text: #1a1d22;
  --muted: #687180;
  --line: #e3e7ee;
  --accent: #2f6fed;
  --green: #2e9e6b;
  --yellow: #cf9700;
  --red: #e23b3b;
  --shadow: 0 6px 20px rgba(20, 30, 60, 0.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Malgun Gothic", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font-family: inherit; cursor: pointer; }
input, select, button { font-size: 16px; } /* iOS 확대 방지 */

/* 앱은 가운데 정렬된 좁은 폭(모바일 느낌) */
#app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  padding-bottom: calc(78px + env(safe-area-inset-bottom)); /* 하단 네비 자리 (+아이폰 홈 바) */
}

/* ---- 상단 앱바 ---- */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  /* 아이폰 홈 화면 앱: 상태바(시계·노치) 아래로 내려서 제목이 가려지지 않게 */
  padding-top: calc(14px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.app-bar .title { font-size: 19px; font-weight: 800; letter-spacing: -0.3px; }
.app-bar .title .logo { color: var(--accent); }
.app-bar .spacer { flex: 1; }
.back-btn {
  border: none; background: var(--surface-2); color: var(--text);
  width: 36px; height: 36px; border-radius: 10px; font-size: 18px;
}
.streak-pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 5px 10px; border-radius: 999px; font-size: 13px; font-weight: 700;
}

/* ---- 뷰 컨테이너 ---- */
.view { padding: 14px 16px 8px; animation: fade 0.18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.view-title { font-size: 16px; font-weight: 800; margin: 4px 2px 12px; }

/* ---- 청결점수 + 펫 카드 ---- */
.score-card {
  display: flex; align-items: center; gap: 16px;
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.score-card .pet { font-size: 46px; line-height: 1; filter: drop-shadow(0 3px 6px rgba(0,0,0,.25)); }
.score-card .pet.happy { animation: bob 2.4s ease-in-out infinite; }
.score-card .pet.sick { filter: grayscale(0.5) drop-shadow(0 3px 6px rgba(0,0,0,.25)); opacity: 0.85; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.score-main { flex: 1; }
.score-num { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; }
.score-num small { font-size: 14px; font-weight: 700; color: var(--muted); }
.score-label { color: var(--muted); font-size: 13px; }
.score-bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.score-bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--red), var(--yellow), var(--green)); }

/* ---- 가족 필터 칩 ---- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text); padding: 8px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 600; white-space: nowrap;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .mini-avatar { width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; color: #fff; font-weight: 800; }
/* 카테고리 필터 칩 (가족 칩보다 작고, 활성 시 외곽선 스타일로 구분) */
.cat-chips { padding-top: 0; margin-top: -2px; }
.cat-chip { font-size: 13px; padding: 6px 12px; }
.cat-chip.active { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); border-color: var(--accent); color: var(--accent); }

/* ---- 섹션 ---- */
.section { margin-top: 8px; }
.section-head { display: flex; align-items: center; gap: 8px; margin: 14px 2px 10px; font-weight: 800; font-size: 14px; color: var(--muted); }
.section-head .count { font-weight: 600; }

/* ---- 카드 그리드 ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(146px, 1fr)); gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 10px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  box-shadow: var(--shadow); transition: transform 0.08s ease;
  user-select: none; -webkit-user-select: none; /* 길게 누르기(선택 모드) 시 글자 선택 방지 */
}
.card:active { transform: scale(0.97); }
.card.shared { background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--accent) 10%, var(--surface))); }
.card-name { font-weight: 700; font-size: 14px; text-align: center; }
.card-sub { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.status-tag { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; }
.status-tag.red { background: color-mix(in srgb, var(--red) 22%, transparent); color: var(--red); }
.status-tag.yellow { background: color-mix(in srgb, var(--yellow) 24%, transparent); color: var(--yellow); }
.status-tag.green { background: color-mix(in srgb, var(--green) 20%, transparent); color: var(--green); }

/* ---- 원형 게이지 ---- */
.gauge { position: relative; display: inline-grid; place-items: center; }
.gauge-svg { transform: rotate(0deg); display: block; }
.gauge-track { stroke: var(--surface-2); }
.gauge-prog { transition: stroke-dashoffset 0.5s ease; }
.gauge-prog.status-green { stroke: var(--green); }
.gauge-prog.status-yellow { stroke: var(--yellow); }
.gauge-prog.status-red { stroke: var(--red); }
.gauge-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.gauge-icon { font-size: 26px; line-height: 1; }
.gauge-dday { font-size: 12px; font-weight: 800; margin-top: 2px; }
.gauge-dday.green { color: var(--green); }
.gauge-dday.yellow { color: var(--yellow); }
.gauge-dday.red { color: var(--red); }

/* 작은 아바타 / 배지 */
.avatar { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; }
.owner-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.badge-shared { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); padding: 2px 8px; border-radius: 999px; font-weight: 700; }

/* ---- 빈 상태 ---- */
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty .big { font-size: 44px; }
.empty p { margin: 10px 0 16px; }

/* ---- 버튼 ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: none; border-radius: 12px; padding: 13px 16px; font-size: 15px; font-weight: 700; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.coupang { background: #ffce4f; color: #2b1d00; } /* 쿠팡 노랑 느낌 */
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.danger { background: color-mix(in srgb, var(--red) 18%, transparent); color: var(--red); }
.btn.block { width: 100%; }
.btn:active { filter: brightness(0.95); }

/* ---- 하단 시트 / 오버레이 ---- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity 0.2s ease; }
.overlay.show { opacity: 1; }
.sheet { width: 100%; max-width: var(--maxw); background: var(--surface); border-radius: 20px 20px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); box-shadow: var(--shadow); transform: translateY(20px); transition: transform 0.22s ease; max-height: 88vh; overflow-y: auto; }
.overlay.show .sheet { transform: none; }
.sheet::before { content: ""; display: block; width: 40px; height: 4px; background: var(--line); border-radius: 999px; margin: 6px auto 12px; }
.sheet { position: relative; }
.sheet-title { font-size: 17px; font-weight: 800; margin: 2px 2px 12px; display: flex; align-items: center; gap: 8px; padding-right: 34px; }
.sheet-close { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--surface-2); color: var(--muted); font-size: 15px; line-height: 1; display: grid; place-items: center; z-index: 3; }
.sheet-close:active { filter: brightness(0.9); }
body.sheet-open { overflow: hidden; }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.menu-btn { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); padding: 14px; border-radius: 12px; font-size: 15px; font-weight: 600; }
.menu-btn .ic { font-size: 20px; width: 24px; text-align: center; }
.menu-btn.danger { color: var(--red); }

/* ---- 폼 (항목/가족 편집) ---- */
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 12px 14px; font-size: 16px;
}
textarea.input { resize: vertical; min-height: 60px; }
.help { font-size: 12px; color: var(--muted); margin-top: 6px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* 주기 변경 UX */
.preset-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chip-sm { border: 1px solid var(--line); background: var(--surface-2); color: var(--text); padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 700; }
.chip-sm.sel { background: var(--accent); border-color: var(--accent); color: #fff; }
.cycle-readout { text-align: center; font-weight: 800; font-size: 22px; margin: 6px 0; }
.cycle-readout small { font-size: 13px; color: var(--muted); font-weight: 700; }
input[type="range"] { width: 100%; accent-color: var(--accent); height: 28px; }

/* 아이콘 픽커 */
.icon-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.icon-opt { font-size: 22px; padding: 8px 0; text-align: center; border-radius: 10px; background: var(--surface-2); border: 1px solid transparent; line-height: 1.2; }
.icon-opt.emoji-initial { background: color-mix(in srgb, var(--accent) 16%, var(--surface-2)); font-weight: 800; }
.icon-opt.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--surface-2)); }

/* 담당/카테고리 선택 칩 */
.pick-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- 번들 카드 (추가 화면) ---- */
.bundle { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
.bundle .b-ic { font-size: 30px; }
.bundle .b-main { flex: 1; }
.bundle .b-name { font-weight: 800; }
.bundle .b-desc { font-size: 12px; color: var(--muted); }

/* ---- 카테고리 다중 선택 (한번에 추가) ---- */
.cat-pick { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); padding: 12px 14px; border-radius: 12px; font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.cat-pick.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface-2)); }
.cat-pick.done { opacity: 0.5; }
.cat-pick .check { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line); display: grid; place-items: center; flex: 0 0 auto; font-size: 14px; color: #fff; font-weight: 800; }
.cat-pick.sel .check { background: var(--accent); border-color: var(--accent); }
.cat-pick .c-ic { font-size: 20px; }
.cat-pick .c-main { flex: 1; }
.cat-pick .c-cnt { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---- 근거(신뢰) 안내 박스 ---- */
.reason-box { background: color-mix(in srgb, var(--green) 12%, var(--surface-2)); border: 1px solid color-mix(in srgb, var(--green) 30%, var(--line)); border-radius: 12px; padding: 12px; font-size: 14px; }
.reason-box .why { font-weight: 700; }
.note-soft { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---- 제휴 고지 ---- */
.disclosure { font-size: 11px; color: var(--muted); text-align: center; margin-top: 8px; line-height: 1.4; }

/* ---- 캘린더 ---- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-title { font-weight: 800; font-size: 16px; }
.cal-nav { display: flex; gap: 8px; }
.cal-nav button { min-width: 38px; width: auto; padding: 0 10px; white-space: nowrap; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-size: 15px; }
.cal-weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-weekdays { margin-bottom: 6px; }
.cal-weekday { text-align: center; font-size: 12px; color: var(--muted); font-weight: 700; }
.cal-weekday.sun { color: var(--red); }
.cal-weekday.sat { color: var(--accent); }
.cal-cell { aspect-ratio: 1 / 1; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); padding: 5px; display: flex; flex-direction: column; align-items: center; font-size: 13px; position: relative; }
.cal-cell.other { opacity: 0.35; }
.cal-cell.today { border-color: var(--accent); border-width: 2px; }
.cal-cell.has { cursor: pointer; }
.cal-daynum { font-weight: 600; }
.cal-dots { display: flex; gap: 3px; margin-top: auto; flex-wrap: wrap; justify-content: center; }
.cal-dot { width: 7px; height: 7px; border-radius: 50%; }
.cal-dot.green { background: var(--green); } .cal-dot.yellow { background: var(--yellow); } .cal-dot.red { background: var(--red); }
.cal-more { font-size: 9px; color: var(--muted); }

/* ---- 통계 ---- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat-card.wide { grid-column: 1 / -1; }
.stat-num { font-size: 24px; font-weight: 800; }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 2px; }
.rank-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rank-row:last-child { border-bottom: none; }
.rank-row .medal { font-size: 20px; width: 26px; text-align: center; }
.rank-row .who { flex: 1; font-weight: 700; }
.rank-row .cnt { color: var(--muted); font-weight: 700; }

/* ---- 인앱 배너 ---- */
.banner { margin: 0 16px 4px; background: color-mix(in srgb, var(--red) 16%, var(--surface)); border: 1px solid color-mix(in srgb, var(--red) 40%, var(--line)); border-radius: 14px; padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
.banner .b-ic { font-size: 22px; }
.banner .b-txt { flex: 1; font-size: 14px; font-weight: 600; }
.banner .b-go { background: var(--red); color: #fff; border: none; border-radius: 10px; padding: 8px 12px; font-weight: 700; font-size: 13px; }
.banner.calm { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.banner.calm .b-go { background: var(--accent); }

/* ---- 하단 네비 ---- */
.bottom-nav {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0;
  width: 100%; max-width: var(--maxw); z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn { background: none; border: none; color: var(--muted); padding: 9px 0 10px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; }
.nav-btn .ic { font-size: 21px; }
.nav-btn.active { color: var(--accent); }
.nav-btn.add .ic { background: var(--accent); color: #fff; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; margin-top: -4px; box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 50%, transparent); }
.nav-btn.add.active .ic { filter: brightness(1.05); }

/* ---- 토스트 ---- */
.toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 700; z-index: 100; opacity: 0; transition: opacity 0.25s, transform 0.25s; box-shadow: var(--shadow); transform: translateX(-50%) translateY(10px); }
.toast.show { opacity: 0.97; transform: translateX(-50%) translateY(0); }

/* ---- 컨페티 ---- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 110; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; opacity: 0.95; animation: fall 1.8s ease-in forwards; }
@keyframes fall { to { transform: translateY(108vh) rotate(540deg); opacity: 0.6; } }

/* 작은 도움 텍스트/구분선 */
.hr { height: 1px; background: var(--line); border: none; margin: 16px 0; }
.muted { color: var(--muted); }
.center { text-align: center; }


/* ============================================================
   1차 UX 개선: 보기 전환 · 검색 · 일괄 선택 · 추가 화면 정리
   ============================================================ */

/* 도구 줄 (보기 전환 + 선택 버튼) */
.tool-row { display: flex; gap: 8px; align-items: stretch; margin: 2px 0 10px; }
.seg { display: flex; flex: 1; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { flex: 1; border: none; background: none; color: var(--muted); font-weight: 700; font-size: 13px; padding: 9px 6px; border-radius: 9px; }
.seg button.on { background: var(--accent); color: #fff; }
.select-btn { flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 0 14px; border-radius: 12px; font-size: 13px; font-weight: 700; min-height: 44px; }
.select-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 검색 입력 */
.search-input { margin: 0 0 10px; }

/* 카드: 카테고리 배지 + 선택 모드 */
.card { position: relative; }
.card-cat { font-size: 11px; color: var(--muted); margin-top: 2px; }
.sel-check { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); color: transparent; display: grid; place-items: center; font-size: 14px; font-weight: 800; z-index: 2; }
.card.selected { outline: 2px solid var(--accent); outline-offset: -2px; }
.card.selected .sel-check { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 일괄 선택 바 (하단 네비 위에 떠 있음) */
.bulk-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(68px + env(safe-area-inset-bottom)); width: calc(100% - 24px); max-width: calc(var(--maxw) - 24px); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 8px; padding: 10px 12px; z-index: 40; }
.bulk-bar .cnt { font-weight: 800; font-size: 14px; flex: 1; }
.btn.sm { padding: 9px 12px; font-size: 13px; min-height: 40px; }

/* 추가 화면: 카테고리 섹션 + '추가됨' 배지 */
.preset-sec { font-size: 14px; font-weight: 700; color: var(--muted); margin: 16px 2px 8px; }
.preset-card.added { opacity: 0.55; }
.added-badge { position: absolute; top: 8px; left: 8px; font-size: 10px; font-weight: 800; color: #fff; background: var(--accent); border-radius: 999px; padding: 3px 7px; z-index: 2; }

/* 실행취소 버튼 달린 토스트 */
.toast.with-action { display: flex; align-items: center; gap: 12px; }
.toast-action { border: none; background: none; color: var(--accent); font-weight: 800; font-size: 14px; padding: 4px 6px; flex: 0 0 auto; }

/* 필터 결과 없음 */
.empty-filter { text-align: center; padding: 24px 0 10px; }
.empty-filter .btn { margin-top: 10px; }


/* ============================================================
   3차 다듬기: 터치 영역 확장 · 시트 버튼 고정 · 칩 크기
   ============================================================ */

/* 작은 버튼들의 '보이는 크기'는 그대로, 실제 누르는 영역만 44px+ 로 확장 */
.back-btn, .cal-nav button { position: relative; }
.sheet-close::after, .back-btn::after, .cal-nav button::after {
  content: ""; position: absolute; inset: -8px;
}

/* 긴 입력 시트에서도 저장/취소 버튼이 항상 보이게 하단 고정 */
.sheet .sheet-actions {
  position: sticky;
  bottom: calc(-20px - env(safe-area-inset-bottom));
  z-index: 2;
  background: var(--surface);
  box-shadow: 0 -10px 14px -10px rgba(0, 0, 0, 0.35);
  padding-top: 10px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  margin-bottom: calc(-20px - env(safe-area-inset-bottom));
}

/* 필터 칩도 살짝 키워 누르기 쉽게 */
.chip { min-height: 40px; }
.chip-sm { min-height: 38px; }


/* ============================================================
   4차 신기능: 장보기 리스트 · 여분 재고 · 교체 이력
   ============================================================ */

/* 장보기 리스트 행 */
.shop-row { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.shop-row:last-of-type { border-bottom: none; }
.shop-ic { font-size: 24px; flex: 0 0 auto; }
.shop-main { flex: 1; min-width: 0; }
.shop-name { font-weight: 700; font-size: 14px; }
.shop-why { font-size: 12px; color: var(--muted); }

/* 카드의 여분 재고 배지 */
.card-stock { font-size: 11px; color: var(--muted); }
.card-stock.out { color: var(--red); font-weight: 800; }

/* 교체 이력 행 */
.hist-row { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.hist-row:last-of-type { border-bottom: none; }
.hist-date { font-weight: 700; }
.hist-who { color: var(--muted); flex: 1; }
.hist-price { color: var(--muted); font-size: 13px; }

/* 안내문 속 줄바꿈(\n)을 실제 줄바꿈으로 */
.empty p, .sheet p.muted { white-space: pre-line; }

/* 서버 보관 코드 (설정 · 불러오기) */
.sync-code-row { display: flex; align-items: center; gap: 10px; }
.sync-code { flex: 1; font-size: 24px; font-weight: 800; letter-spacing: 2px; font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; user-select: all; -webkit-user-select: all; }
.code-input { text-transform: uppercase; letter-spacing: 2px; font-weight: 700; font-size: 20px; text-align: center; }
.code-input::placeholder { letter-spacing: 1px; font-weight: 500; text-transform: none; }
