/* 공통 컴포넌트 모양. 화면별 CSS는 pages.css */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--c-text);
  background: #E3F1F7;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
img, svg { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--c-primary); outline-offset: 2px; }
/* '동작 줄이기'를 켠 사용자: 움직임 효과를 끈다 (기능은 그대로) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 앱 틀: 폰 폭으로 가운데 */
.app {
  max-width: var(--page-max);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--c-bg);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + var(--sp-6));
  position: relative;
  overflow-x: hidden;
}
.page { padding: 0 var(--sp-5); }
.stack > * + * { margin-top: var(--sp-4); }

/* Header */
.header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: calc(var(--sp-5) + env(safe-area-inset-top)) var(--sp-5) var(--sp-3);
}
.header__eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .12em; color: var(--c-primary); }
.header__title { margin: 0; font-size: var(--fs-xl); font-weight: 800; letter-spacing: -.02em; }
.header__back {
  display: inline-flex; align-items: center; gap: var(--sp-1); min-height: var(--tap);
  color: var(--c-primary); font-weight: 700; font-size: var(--fs-sm);
}
.header__side { display: flex; align-items: center; gap: var(--sp-2); }
.user-pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 var(--sp-3);
  border-radius: var(--r-pill); background: var(--c-white); box-shadow: var(--shadow-card);
  font-size: var(--fs-xs); font-weight: 700; color: var(--c-deep); max-width: 150px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 큰 제목 */
.hero { margin: var(--sp-2) 0 var(--sp-5); }
.hero h2 { margin: 0; font-size: var(--fs-2xl); line-height: 1.3; letter-spacing: -.03em; font-weight: 800; }
.hero p { margin: var(--sp-2) 0 0; color: var(--c-muted); font-size: var(--fs-sm); }
.accent { color: var(--c-primary); }

/* Card */
.card {
  background: var(--c-white); border-radius: var(--r-lg); box-shadow: var(--shadow-card);
  padding: var(--sp-5);
}
.card--sky { background: var(--c-sky); box-shadow: none; }
.card__title { margin: 0; font-size: var(--fs-lg); font-weight: 800; }
.card__sub { margin: 2px 0 0; color: var(--c-muted); font-size: var(--fs-xs); }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: var(--sp-8) 0 var(--sp-3); }
.section-title h3 { margin: 0; font-size: var(--fs-lg); font-weight: 800; }
.section-title a { font-size: var(--fs-xs); color: var(--c-primary); font-weight: 700; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 52px; padding: 0 var(--sp-6); border-radius: var(--r-md); border: 0;
  font-size: var(--fs-md); font-weight: 800; cursor: pointer; transition: transform .1s, background .2s; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--c-primary); color: var(--c-white); box-shadow: 0 6px 16px rgba(35, 148, 191, .28); }
.btn--primary:hover { background: var(--c-deep); }
.btn--secondary { background: var(--c-white); color: var(--c-deep); border: 1.5px solid var(--c-line); }
.btn--secondary:hover { border-color: var(--c-primary); }
.btn--ghost { background: transparent; color: var(--c-muted); min-height: var(--tap); font-weight: 700; font-size: var(--fs-sm); }
.btn--small { min-height: 40px; padding: 0 var(--sp-4); font-size: var(--fs-sm); border-radius: var(--r-pill); }
.btn--block { display: flex; width: 100%; }

/* Badge / Chip */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: var(--r-pill);
  background: var(--c-sky); color: var(--c-deep); font-size: var(--fs-xs); font-weight: 700; white-space: nowrap;
}
.badge--solid { background: var(--c-primary); color: var(--c-white); }
.badge--mint { background: #E3F6EC; color: #237A52; }
.badge--sample { background: #FFF4D6; color: #8A6400; }
.chips { display: flex; gap: var(--sp-2); overflow-x: auto; padding: 2px 2px var(--sp-1); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips--wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 4px; min-height: 38px; padding: 0 var(--sp-4);
  border-radius: var(--r-pill); border: 1.5px solid var(--c-line); background: var(--c-white);
  font-size: var(--fs-sm); font-weight: 700; color: var(--c-text); cursor: pointer;
}
.chip[aria-pressed="true"], .chip:has(input:checked) { background: var(--c-primary); border-color: var(--c-primary); color: var(--c-white); }
.chip input { position: absolute; opacity: 0; pointer-events: none; }

/* Form */
.field { display: block; }
.field + .field { margin-top: var(--sp-5); }
.field__label { display: block; margin-bottom: var(--sp-2); font-size: var(--fs-sm); font-weight: 800; }
.field__hint { margin-top: 6px; font-size: var(--fs-xs); color: var(--c-muted); }
.field__error { margin-top: 6px; font-size: var(--fs-xs); color: var(--c-danger); font-weight: 700; min-height: 0; }
.field__error:empty { display: none; }
.input, .textarea, .select {
  width: 100%; min-height: 52px; padding: 14px var(--sp-4); border-radius: var(--r-md);
  border: 1.5px solid var(--c-line); background: var(--c-white);
  font-size: 16px; /* 16px 미만이면 아이폰이 확대해 버린다 */
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--c-muted) 50%), linear-gradient(135deg, var(--c-muted) 50%, transparent 50%);
  background-position: calc(100% - 22px) 23px, calc(100% - 16px) 23px; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 4px rgba(35, 148, 191, .15); }
.field.has-error .input, .field.has-error .textarea, .field.has-error .select { border-color: var(--c-danger); }
.input[disabled], .textarea[disabled] { background: #F0F5F8; color: var(--c-muted); }

/* PlaceCard */
.place-list { display: grid; gap: var(--sp-4); }
.place-card { display: block; background: var(--c-white); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-card); }
.place-card__media { position: relative; aspect-ratio: 16 / 9; background: var(--c-sky); }
.place-card__media img, .place-card__media svg { width: 100%; height: 100%; object-fit: cover; }
.place-card__tag { position: absolute; left: var(--sp-3); top: var(--sp-3); }
.place-card__body { padding: var(--sp-4); min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.place-card__body > .badge--sample { flex: none; }
.place-card__title { margin: 0; font-size: var(--fs-md); font-weight: 800; line-height: 1.4; width: 100%;
  overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.place-card__meta { margin: 0; width: 100%; min-width: 0; overflow-wrap: anywhere; display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: var(--fs-xs); color: var(--c-muted); }
.place-card--row { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: start; gap: var(--sp-3); padding: var(--sp-3); }
.place-card--row .place-card__media { width: 96px; aspect-ratio: 1; border-radius: var(--r-md); overflow: hidden; }
.place-card--row .place-card__body { padding: 2px 0; }
.place-card--row .place-card__tag { display: none; }

/* RegionCard */
.region-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.region-card {
  display: flex; flex-direction: column; gap: 6px; padding: var(--sp-4); border-radius: var(--r-md);
  background: var(--c-white); box-shadow: var(--shadow-card); min-height: 92px;
}
/* 좁은 2열 카드 안 버튼: .btn 의 nowrap·좌우 여백 때문에 320px에서 글자가 잘렸다 → 줄바꿈 허용, 여백 줄임 */
.region-card .btn { white-space: normal; text-align: center; line-height: 1.25; padding: 4px 8px; }
.region-card__name { font-weight: 800; }
.region-card__meta { font-size: var(--fs-xs); color: var(--c-muted); }
.meter { height: 6px; border-radius: var(--r-pill); background: var(--c-sky); overflow: hidden; margin-top: auto; }
.meter > i { display: block; height: 100%; background: linear-gradient(90deg, var(--c-mint), var(--c-primary)); border-radius: inherit; }

/* Loading / Empty / Error / WIP state */
.state { text-align: center; padding: var(--sp-8) var(--sp-5); color: var(--c-muted); }
.state__icon { font-size: 40px; line-height: 1; margin-bottom: var(--sp-3); }
.state__title { margin: 0; color: var(--c-text); font-size: var(--fs-md); font-weight: 800; }
.state__text { margin: 6px 0 0; font-size: var(--fs-sm); }
.state .btn { margin-top: var(--sp-4); }
.state--error .state__title { color: var(--c-danger); }
.state--wip { background: #FFF9E8; border: 1.5px dashed #F2CF6B; border-radius: var(--r-lg); }
.spinner { width: 32px; height: 32px; margin: 0 auto var(--sp-3); border-radius: 50%; border: 4px solid var(--c-sky); border-top-color: var(--c-primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, #EDF4F8 25%, #F7FBFD 50%, #EDF4F8 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--r-lg); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* BottomNavigation */
.bottom-nav {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 20;
  width: 100%; max-width: var(--page-max);
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--c-line); border-radius: 20px 20px 0 0;
}
.bottom-nav__item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 700; color: var(--c-muted);
}
.bottom-nav__item svg { width: 24px; height: 24px; }
.bottom-nav__item[aria-current="page"] { color: var(--c-primary); }
.bottom-nav__item--write .bottom-nav__icon {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--c-primary); color: var(--c-white);
}
.bottom-nav__item--write .bottom-nav__icon svg { width: 20px; height: 20px; }

/* Toast */
.toast-wrap { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 40; width: calc(100% - 40px); max-width: 440px; display: grid; gap: 8px; pointer-events: none; }
.toast { padding: 14px 18px; border-radius: var(--r-md); background: var(--c-text); color: var(--c-white); font-size: var(--fs-sm); font-weight: 700; box-shadow: var(--shadow-float); animation: toast-in .2s ease-out; }
.toast--error { background: var(--c-danger); }
.toast--ok { background: var(--c-deep); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Dialog (alert/confirm 대신) */
.dialog { border: 0; padding: 0; border-radius: var(--r-lg); width: min(360px, calc(100% - 40px)); box-shadow: var(--shadow-float); color: var(--c-text); }
.dialog::backdrop { background: rgba(22, 56, 75, .45); }
.dialog__body { padding: var(--sp-6) var(--sp-5) var(--sp-4); text-align: center; }
.dialog__icon { font-size: 40px; margin-bottom: var(--sp-2); }
.dialog__title { margin: 0; font-size: var(--fs-lg); font-weight: 800; }
.dialog__text { margin: var(--sp-2) 0 0; color: var(--c-muted); font-size: var(--fs-sm); }
.dialog__actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); padding: 0 var(--sp-5) var(--sp-5); }
.dialog__actions:has(> :only-child) { grid-template-columns: 1fr; }
.dialog__actions .btn { min-height: 48px; padding: 0 var(--sp-3); }

/* 출처 표기 */
.credit { margin: var(--sp-8) 0 0; font-size: 11px; color: var(--c-muted); line-height: 1.6; }
