/* 공용 부품 — includes/ui.php 가 이 마크업을 만든다. 화면 이름(.homes-…)을 넣지 않는다. 견본: /dev/components */

/* ── 버튼 ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--control-h-md); padding: 0 var(--space-5);
  border: 1px solid transparent; border-radius: var(--r-sm); cursor: pointer;
  font-size: var(--text-md); font-weight: var(--weight-bold); line-height: 1; text-decoration: none; white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
  touch-action: manipulation;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); color: var(--on-primary); }
.btn-accent { background: var(--accent); color: var(--on-accent); }   /* 보조 동작 하나에만(DESIGN §2) */
.btn-accent:hover { background: var(--accent-hover); color: var(--on-accent); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--primary-ink); }
.btn-ghost:hover { background: var(--primary-soft); color: var(--primary-ink); }
.btn-danger { background: var(--danger); color: var(--on-danger); }
.btn-danger:hover { filter: brightness(.95); color: var(--on-danger); }
.btn-sm { min-height: var(--control-h-sm); padding: 0 var(--space-4); font-size: var(--text-sm); }
.btn-lg { min-height: var(--control-h-lg); padding: 0 var(--space-6); font-size: var(--text-lg); }
.btn-block { width: 100%; }
.btn-icon { width: var(--control-h-md); padding: 0; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--on-primary); border-right-color: transparent; animation: spin .7s linear infinite;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after { border-color: var(--primary); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 auto; }

/* ── 입력 ── */
.field { display: grid; gap: var(--space-2); }
.field-label { font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--text); }
.field-label .opt { font-weight: var(--weight-normal); color: var(--text-3); margin-left: var(--space-1); }
.field-hint { font-size: var(--text-sm); color: var(--text-3); }
.field-error { font-size: var(--text-sm); color: var(--danger); }
.input, .textarea {
  width: 100%; min-height: var(--control-h-md); padding: 0 var(--space-4);
  background: var(--surface-2); color: var(--text);   /* 회색 채움 칸 — 테두리는 포커스·오류 때만 */
  border: 1px solid transparent; border-radius: var(--r-sm);
  font-size: var(--text-md);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.textarea { padding: var(--space-3) var(--space-4); min-height: 120px; resize: vertical; }
.input::placeholder { color: var(--text-3); }
.input:focus, .textarea:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px var(--primary-soft); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input[disabled], .input[readonly] { background: var(--surface-2); color: var(--text-2); }
.input-group { display: flex; gap: var(--space-2); }
.input-group > .input { flex: 1 1 auto; min-width: 0; }
.input-group > .btn { flex: none; }
.input-suffix { position: relative; }
.input-suffix > .input { padding-right: 56px; }
.input-suffix > .suffix { position: absolute; right: var(--space-4); top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: var(--text-sm); pointer-events: none; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.check { display: flex; gap: var(--space-3); align-items: flex-start; min-height: 44px; padding: var(--space-2) 0; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--primary); flex: none; }
.radio-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.radio-card { position: relative; }
.radio-card input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.radio-card span {
  display: flex; align-items: center; justify-content: center; min-height: var(--control-h-md); padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-strong); border-radius: var(--r); background: var(--surface); text-align: center; font-weight: var(--weight-medium);
}
.radio-card input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-ink); font-weight: var(--weight-bold); box-shadow: inset 0 0 0 1px var(--primary); }
.radio-card input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.form-grid { display: grid; gap: var(--space-4); }
@media (min-width: 600px) { .form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }

/* ── 카드·배지·알림 상자 ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--space-6) var(--space-5); box-shadow: var(--shadow-card); }
/* 카드 아래쪽 줄: 왼쪽 짧은 설명 + 오른쪽 주 버튼 */
.card-foot { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; justify-content: space-between; margin-top: var(--space-5); }
.card-foot p { font-size: var(--text-sm); color: var(--text-2); }
.card-eyebrow { font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--text-2); }
.em { color: var(--primary-ink); }
/* 탭(회색 바탕 위 흰 알약 — 주소 검색 카드 위) */
.tabs { display: inline-flex; gap: 2px; padding: 4px; border-radius: var(--r-sm); background: var(--surface-2); flex-wrap: wrap; }
.tabs a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 var(--space-4); border-radius: 6px; color: var(--text-3); text-decoration: none; font-size: var(--text-sm); font-weight: var(--weight-bold); }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.card-link { display: block; color: inherit; text-decoration: none; transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease); }
.card-link:hover { border-color: var(--border-strong); color: inherit; }
.card-title { font-size: var(--text-lg); font-weight: var(--weight-bold); }
.card-sub { color: var(--text-2); font-size: var(--text-sm); }
.card-flat { box-shadow: none; background: var(--surface-2); border-color: transparent; }
@media (min-width: 600px) { .card { padding: var(--space-7); } }

.badge { display: inline-flex; align-items: center; gap: var(--space-1); min-height: 26px; padding: 0 var(--space-3); border-radius: var(--r-full); font-size: var(--text-xs); font-weight: var(--weight-bold); white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge-primary { background: var(--primary-soft); color: var(--primary-ink); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-success { background: var(--success-soft); color: var(--success); }

.alert { display: flex; gap: var(--space-3); padding: var(--space-4); border-radius: var(--r); background: var(--surface-2); color: var(--text); font-size: var(--text-sm); border: 1px solid var(--border); }
.alert svg { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.alert-info { background: var(--primary-soft); border-color: transparent; }
.alert-info svg { color: var(--primary-ink); }
.alert-warn { background: var(--warn-soft); border-color: transparent; }
.alert-warn svg { color: var(--warn); }
.alert-error { background: var(--danger-soft); border-color: transparent; }
.alert-error svg { color: var(--danger); }
.alert-success { background: var(--success-soft); border-color: transparent; }
.alert-success svg { color: var(--success); }
.alert strong { display: block; margin-bottom: 2px; }
.dev-code { font-variant-numeric: tabular-nums; font-size: var(--text-lg); letter-spacing: .12em; }

/* ── 빈 상태·스켈레톤·진행 막대 ── */
.empty { text-align: center; padding: var(--space-8) var(--space-4); display: grid; gap: var(--space-3); justify-items: center; }
.empty svg { width: 40px; height: 40px; color: var(--text-3); }
.empty-title { font-size: var(--text-lg); font-weight: var(--weight-bold); }
.empty p { color: var(--text-2); max-width: 36ch; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--r-sm); min-height: 16px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.progress { height: 8px; background: var(--surface-3); border-radius: var(--r-full); overflow: hidden; }
.progress > span { display: block; height: 100%; width: var(--pct, 0%); background: var(--primary); border-radius: inherit; }

/* ── 큰 숫자(남은 날 등) ── */
.bignum { display: grid; gap: var(--space-1); }
.bignum-value { font-size: var(--text-num); font-weight: var(--weight-heavy); line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--text); }
.bignum-value small { font-size: var(--text-xl); font-weight: var(--weight-bold); margin-left: var(--space-1); letter-spacing: 0; }
.bignum-label { font-size: var(--text-sm); color: var(--text-2); }

/* ── 정의 목록(값 표) ── */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-2) var(--space-4); margin: 0; font-size: var(--text-sm); }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; font-weight: var(--weight-medium); }

/* ── 표(모바일에선 카드로) ── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th, .table td { padding: var(--space-3) var(--space-4); text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--text-2); font-weight: var(--weight-bold); background: var(--surface-2); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
@media (max-width: 599px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
  .table-cards td { border: 0; padding: var(--space-1) 0; display: flex; justify-content: space-between; gap: var(--space-3); }
  .table-cards td::before { content: attr(data-label); color: var(--text-2); font-weight: var(--weight-medium); }
  .table-cards .num { text-align: right; }
}

/* ── 목록 줄 ── */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.list-row { display: flex; gap: var(--space-3); align-items: center; justify-content: space-between; padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); color: inherit; text-decoration: none; min-height: 56px; }
a.list-row:hover { border-color: var(--border-strong); color: inherit; }
.list-row .chev { width: 20px; height: 20px; color: var(--text-3); flex: none; }

/* ── 페이지 넘김 ── */
.pager { display: flex; gap: var(--space-2); justify-content: center; flex-wrap: wrap; }
.pager a, .pager span { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; border-radius: var(--r-sm); text-decoration: none; color: var(--text-2); }
.pager a:hover { background: var(--surface-2); }
.pager [aria-current="page"] { background: var(--primary); color: var(--on-primary); font-weight: var(--weight-bold); }

/* ── 단계 표시(번호 목록 — 같은 카드 격자 대신 세로 줄) ── */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-4); counter-reset: step; }
.steps > li { display: grid; grid-template-columns: 36px 1fr; gap: var(--space-3); align-items: start; counter-increment: step; }
.steps > li::before { content: counter(step); display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-full); background: var(--primary-soft); color: var(--primary-ink); font-weight: var(--weight-bold); }
.steps h3 { font-size: var(--text-md); margin-bottom: var(--space-1); }
.steps p { color: var(--text-2); font-size: var(--text-sm); }

/* ── 토스트 ── */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--space-5) + env(safe-area-inset-bottom)); z-index: 90; display: grid; gap: var(--space-2); width: min(92vw, 420px); pointer-events: none; }
.has-tabbar .toasts { bottom: calc(80px + env(safe-area-inset-bottom)); }
.toast { pointer-events: auto; display: flex; gap: var(--space-3); align-items: center; padding: var(--space-3) var(--space-4); min-height: 48px; border-radius: var(--r); background: var(--tip-bg); color: var(--tip-text); box-shadow: var(--shadow-2); font-size: var(--text-sm); animation: toast-in .2s var(--ease); }
.toast svg { width: 20px; height: 20px; flex: none; }
.toast-error svg { color: var(--tip-err); }
.toast-success svg { color: var(--tip-ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ── 확인 대화상자(브라우저 confirm 대신) ── */
.dialog { border: 0; padding: 0; background: transparent; max-width: min(92vw, 440px); width: 100%; color: var(--text); }
.dialog::backdrop { background: var(--overlay); }
.dialog-box { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-2); display: flex; flex-direction: column; max-height: min(86vh, 86dvh); }
.dialog-body { padding: var(--space-6) var(--space-6) var(--space-4); overflow-y: auto; overscroll-behavior: contain; display: grid; gap: var(--space-3); }
.dialog-title { font-size: var(--text-lg); }
.dialog-body p { color: var(--text-2); }
.dialog-actions { display: flex; gap: var(--space-2); justify-content: flex-end; padding: var(--space-4) var(--space-6) var(--space-6); flex-wrap: wrap; }
.dialog-actions .btn { flex: 1 1 120px; }

/* ── 콤보박스(기본 select 펼침 대신 — 규칙서 §8-1) ── */
.cbx { position: relative; }
.cbx-native { position: absolute !important; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.cbx-input { padding-right: 44px; cursor: text; }
.cbx-arrow { position: absolute; right: 4px; top: 4px; width: 40px; height: 40px; display: grid; place-items: center; color: var(--text-3); pointer-events: none; }
.cbx-arrow svg { width: 20px; height: 20px; }
.cbx-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40; margin: 0; padding: var(--space-1); list-style: none; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r); box-shadow: var(--shadow-2); max-height: 280px; overflow-y: auto; }
.cbx.is-up .cbx-list { top: auto; bottom: calc(100% + 4px); }
.cbx-list[hidden] { display: none; }
.cbx-opt { display: flex; align-items: center; min-height: 44px; padding: 0 var(--space-3); border-radius: var(--r-sm); cursor: pointer; }
.cbx-opt[aria-selected="true"] { font-weight: var(--weight-bold); color: var(--primary-ink); }
.cbx-opt.is-active { background: var(--primary-soft); }
.cbx-empty { padding: var(--space-3); color: var(--text-3); font-size: var(--text-sm); }

/* ── 툴팁(기본 title 대신 — 규칙서 §8-1) ── */
.tip { position: fixed; z-index: 100; max-width: 260px; padding: var(--space-2) var(--space-3); border-radius: var(--r-sm); background: var(--tip-bg); color: var(--tip-text); font-size: var(--text-xs); line-height: 1.5; box-shadow: var(--shadow-2); pointer-events: none; opacity: 0; transition: opacity 120ms var(--ease); }
.tip.is-on { opacity: 1; }

/* ── 아이콘 ── */
.icon { width: 20px; height: 20px; flex: none; }
