/* components.css | 버튼, 입력칸, 카드, 팝업, 알림 등 어디서나 쓰는 부품 */
.icon { flex: none; }

/* ---- 버튼 ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: .55rem 1.1rem; border: 1px solid transparent; border-radius: 999px; white-space: nowrap;
  font-weight: 700; background: var(--primary); color: #fff; text-decoration: none; transition: background .15s, transform .05s, box-shadow .15s;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { min-height: 36px; padding: .3rem .8rem; font-size: .875rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(116, 89, 217, .30); }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-soft:hover { background: #e4dafc; }
.btn-outline { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-text { background: transparent; color: var(--muted); padding-inline: .5rem; min-height: 32px; font-weight: 600; }
.btn-text:hover { background: var(--surface-2); color: var(--primary); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { background: #9d1f17; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--primary); }
.fab {
  position: fixed; right: 1.1rem; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 1rem); z-index: 25;
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  background: var(--coral); color: #fff; box-shadow: 0 8px 22px rgba(255, 122, 105, .45);
}
.fab:hover { text-decoration: none; filter: brightness(.95); }
@media (min-width: 900px) { .fab { bottom: 2rem; right: max(2rem, calc((100vw - var(--maxw)) / 2)); } }

/* ---- 카드/배지/칩 ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.actions { display: flex; gap: .6rem; justify-content: flex-end; align-items: center; }
.actions.wrap { flex-wrap: wrap; justify-content: flex-start; }
.badge { display: inline-flex; align-items: center; gap: .25rem; padding: .15rem .6rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: .75rem; font-weight: 700; }
.badge-soft { background: var(--surface-2); color: var(--muted); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.chips-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .4rem; }
.chips { display: flex; gap: .5rem; overflow-x: auto; padding: .25rem 0 .75rem; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: .4rem .95rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: .9rem; font-weight: 600; color: var(--muted); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---- 폼 ---- */
.field { display: flex; flex-direction: column; gap: .35rem; }
.field label { font-weight: 700; font-size: .9rem; }
.optional { font-weight: 400; color: var(--muted); }
input[type='text'], input[type='email'], input[type='password'], input[type='search'], select, textarea {
  width: 100%; min-height: 46px; padding: .6rem .85rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--sea); box-shadow: 0 0 0 3px rgba(116, 89, 217, .20); }
.input-wrap { position: relative; }
.input-wrap input { padding-right: 4.5rem; }
.field-toggle { position: absolute; right: .25rem; top: 50%; transform: translateY(-50%); }
.hint { font-size: .8rem; color: var(--muted); margin: 0; }
.hint.good { color: var(--good); } .hint.bad { color: var(--bad); }
.form-error { background: var(--bad-soft); color: var(--bad); border-radius: var(--radius-sm); padding: .6rem .85rem; margin: 0; font-size: .9rem; font-weight: 600; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-size: .9rem; }
.check input { margin-top: .25rem; width: 18px; height: 18px; accent-color: var(--primary); }
.is-busy { opacity: .75; pointer-events: none; }
.select-sm { width: auto; min-height: 38px; padding: .3rem .7rem; border-radius: 999px; font-size: .875rem; }

/* ---- 팝업 / 알림 ---- */
.dialog { border: 0; border-radius: 20px; padding: 0; width: min(92vw, 440px); box-shadow: var(--shadow-lg); color: var(--text); }
.dialog::backdrop { background: rgba(10, 35, 60, .5); backdrop-filter: blur(2px); }
.dialog-body { padding: 1.25rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; }
.lightbox { padding: .75rem; display: flex; flex-direction: column; gap: .75rem; align-items: center; }
.lightbox img { max-height: 75vh; object-fit: contain; border-radius: 10px; }
.dialog:has(.lightbox) { width: min(96vw, 900px); }
#toasts { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 1rem); display: flex; flex-direction: column; gap: .5rem; align-items: center; width: min(92vw, 420px); pointer-events: none; }
.toast { pointer-events: auto; background: var(--text); color: #fff; padding: .7rem 1.1rem; border-radius: 999px; font-weight: 600; font-size: .9rem; box-shadow: var(--shadow-lg); animation: pop .25s ease-out; }
.toast-success { background: var(--good); } .toast-error { background: var(--bad); }
.toast.out { opacity: 0; transition: opacity .3s; }
@keyframes pop { from { transform: translateY(10px); opacity: 0; } }

/* ---- 상태 ---- */
.spinner-wrap { display: grid; place-items: center; padding: 2rem; }
.spinner { width: 32px; height: 32px; border: 4px solid var(--primary-soft); border-top-color: var(--sea); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.empty h3 { color: var(--text); margin: 0; }
.empty-icon { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary); }
.empty-error { color: var(--bad); }

/* ---- 아바타 / 작성자 ---- */
.avatar { --size: 40px; position: relative; display: inline-grid; place-items: center; flex: none; width: var(--size); height: var(--size); border-radius: 50%; overflow: hidden; border: 1px solid var(--border); background: var(--avatar-bg, #efe9ff); color: var(--avatar-ink, #5b3fd0); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; -webkit-user-drag: none; }   /* 눌러도 확대/미리보기 없음 */
.avatar-initial { font-weight: 800; font-size: calc(var(--size) * .46); line-height: 1; }
.avatar-tint-0 { --avatar-bg: #efe9ff; --avatar-ink: #5b3fd0; }
.avatar-tint-1 { --avatar-bg: #ffe9ef; --avatar-ink: #c2335d; }
.avatar-tint-2 { --avatar-bg: #e3f6ec; --avatar-ink: #1f7a4d; }
.avatar-tint-3 { --avatar-bg: #e4f0ff; --avatar-ink: #1f5fb8; }
.avatar-tint-4 { --avatar-bg: #fff1dc; --avatar-ink: #a65a00; }
.avatar-tint-5 { --avatar-bg: #e2f6f7; --avatar-ink: #12767d; }
.author { display: inline-flex; align-items: center; gap: .45rem; color: var(--text); font-weight: 600; font-size: .9rem; }
.author:hover { text-decoration: none; color: var(--primary); }
.field .label { font-weight: 700; font-size: .9rem; }
