/* 공용 컴포넌트. 이름 규칙: .블록, .블록__요소, .블록--변형, 상태는 .is-상태 / aria-* / data-state */

/* ── 아이콘 동그라미 ── */
.bubble { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary-ink); }
.bubble--ok { background: var(--success-bg); color: var(--success-ink); }
.bubble--warn { background: var(--warn-bg); color: var(--warn-ink); }
.bubble--danger { background: var(--danger-bg); color: var(--danger-ink); }
.bubble--plain { background: var(--surface-2); color: var(--ink-2); }
.bubble--l { width: 64px; height: 64px; border-radius: 20px; }
.bubble--l .icon { width: 32px; height: 32px; }

/* ── 버튼 ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--tap); padding: 0 22px; border: 2px solid transparent; border-radius: var(--r-ctrl);
  font-weight: 700; font-size: var(--fs-m); line-height: 1.2; text-decoration: none; text-align: center;
  background: var(--surface); color: var(--ink); position: relative; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform 80ms var(--ease);
}
.btn:active:not(:disabled):not([aria-disabled="true"]) { transform: scale(.98); }
.btn:focus-visible { box-shadow: var(--focus-ring); border-radius: var(--r-ctrl); }
.btn--primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 2px 0 var(--primary-press); }
.btn--primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn--primary:active:not(:disabled) { background: var(--primary-press); box-shadow: none; }
.btn--secondary { background: var(--primary-soft); color: var(--primary-ink); }
.btn--secondary:hover:not(:disabled) { background: #CDE9E4; }
.btn--ghost { background: transparent; color: var(--ink-2); border-color: var(--line-strong); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn--danger { background: var(--danger); color: #fff; box-shadow: 0 2px 0 #8f2218; }
.btn--danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn--s { min-height: 40px; padding: 0 14px; font-size: var(--fs-s); border-radius: 12px; }
.btn--l { min-height: 56px; padding: 0 28px; font-size: var(--fs-l); border-radius: 16px; }
.btn--block { display: flex; width: 100%; }
.btn--icon { width: var(--tap); padding: 0; }
.btn--icon.btn--s { width: 40px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn.is-loading { cursor: progress; }
.btn.is-loading > :not(.btn__spinner) { opacity: .0; }
.btn__spinner { position: absolute; inset: 0; display: grid; place-items: center; }
.btn__spinner .icon { animation: spin .9s linear infinite; }
.btn.is-loading { pointer-events: none; }

/* ── 카드 ── */
.card { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-1); padding: var(--s-5) var(--s-4); display: flex; flex-direction: column; gap: var(--s-4); border: 1px solid var(--line); }
.card--flat { box-shadow: none; }
.card--tint { background: var(--primary-soft); border-color: transparent; box-shadow: none; }
.card--hero { padding: var(--s-6) var(--s-4); text-align: center; align-items: center; }
.card__head { display: flex; align-items: center; gap: var(--s-3); }
.card__title { font-size: var(--fs-l); font-weight: 800; letter-spacing: -.02em; line-height: 1.35; }
.card__sub { color: var(--muted); font-size: var(--fs-s); }
.card__actions { display: flex; gap: var(--s-3); flex-wrap: wrap; }
.card__actions > .btn { flex: 1 1 140px; }

/* ── 단계 표시 ── */
.stepper { display: flex; align-items: flex-start; gap: 0; counter-reset: none; }
.stepper__item { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: var(--s-2); position: relative; text-align: center; }
.stepper__item::before { content: ''; position: absolute; top: 15px; right: 50%; width: 100%; height: 3px; background: var(--line); z-index: 0; border-radius: 2px; }
.stepper__item:first-child::before { display: none; }
.stepper__item[data-state="done"]::before, .stepper__item[data-state="current"]::before { background: var(--success-solid); }
.stepper__dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: var(--fs-s); background: var(--surface); border: 2px solid var(--line-strong); color: var(--muted); position: relative; z-index: 1; }
.stepper__item[data-state="done"] .stepper__dot { background: var(--success); border-color: var(--success); color: #fff; }
.stepper__item[data-state="current"] .stepper__dot { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 0 0 5px var(--primary-soft); }
.stepper__dot .icon { width: 16px; height: 16px; stroke-width: 3; }
.stepper__label { font-size: var(--fs-s); font-weight: 600; color: var(--muted); line-height: 1.3; padding: 0 2px; }
.stepper__item[data-state="current"] .stepper__label { color: var(--ink); font-weight: 800; }
.stepper__item[data-state="done"] .stepper__label { color: var(--success-ink); }
.stepper__item > button { all: unset; display: contents; cursor: pointer; }
.stepper__summary { display: none; font-weight: 800; }
@media (max-width: 559px) {
  /* 좁은 화면: 점만 보이고 지금 단계 이름은 위에 한 줄로 */
  .stepper-wrap { display: flex; flex-direction: column; gap: var(--s-3); }
  .stepper__summary { display: block; text-align: center; }
  .stepper__label { display: none; }
}

/* ── 진행 막대 ── */
.progress { height: 12px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.progress__bar { height: 100%; width: calc(var(--value, 0) * 1%); background: linear-gradient(90deg, var(--primary), var(--mint-strong)); border-radius: inherit; transition: width .4s var(--ease); }
.progress--ok .progress__bar { background: linear-gradient(90deg, var(--success), var(--success-solid)); }
.progress--s { height: 8px; }

/* ── 깔때기 ── */
.funnel { display: flex; align-items: stretch; gap: var(--s-2); }
.funnel__step { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; padding: var(--s-3); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.funnel__num { font-size: var(--fs-xl); font-weight: 800; letter-spacing: -.03em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.funnel__unit { font-size: var(--fs-s); font-weight: 600; color: var(--muted); margin-left: 2px; }
.funnel__label { font-size: var(--fs-s); color: var(--ink-2); font-weight: 600; }
.funnel__track { height: 8px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; margin-top: auto; }
.funnel__fill { height: 100%; width: calc(var(--ratio, 1) * 100%); min-width: 6px; border-radius: inherit; background: var(--primary); opacity: calc(.45 + var(--ratio, 1) * .55); }
.funnel__step:last-child { background: var(--primary-soft); border-color: transparent; }
.funnel__step:last-child .funnel__num { color: var(--primary-ink); }
@media (max-width: 559px) {
  .funnel { flex-direction: column; }
  .funnel__step { display: grid; grid-template-columns: 1fr auto; align-items: baseline; column-gap: var(--s-3); row-gap: 6px; padding: var(--s-3) var(--s-4); }
  .funnel__label { grid-column: 1; grid-row: 1; }
  .funnel__value { grid-column: 2; grid-row: 1; text-align: right; }
  .funnel__track { grid-column: 1 / -1; grid-row: 2; }
}

/* ── 선택 버튼 ── */
.choices { display: grid; gap: var(--s-3); grid-template-columns: 1fr; }
.choices--2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.choice {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; min-height: 72px; padding: var(--s-3) var(--s-4);
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--r-card); text-align: left; box-shadow: var(--shadow-1);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.choice:hover { border-color: var(--line-strong); }
.choice:active:not(:disabled) { transform: scale(.99); }
.choice__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.choice__title { font-weight: 800; font-size: var(--fs-m); line-height: 1.35; }
.choice__desc { font-size: var(--fs-s); color: var(--muted); line-height: 1.4; }
.choice__check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line-strong); display: grid; place-items: center; flex: none; color: transparent; }
.choice__check .icon { width: 16px; height: 16px; stroke-width: 3; }
.choice[aria-checked="true"] { border-color: var(--primary); background: var(--primary-soft); }
.choice[aria-checked="true"] .choice__check { background: var(--primary); border-color: var(--primary); color: #fff; }
.choice[aria-checked="true"] .bubble { background: var(--surface); }
.choice:disabled { opacity: .5; cursor: not-allowed; }
.choice:focus-visible { box-shadow: var(--focus-ring); border-radius: var(--r-card); }

/* ── 상태 칩 ── */
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 2px 12px 2px 8px; border-radius: var(--r-pill); font-size: var(--fs-s); font-weight: 700; line-height: 1.2; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); }
.chip .icon { width: 16px; height: 16px; }
.chip--ok { background: var(--success-bg); color: var(--success-ink); }
.chip--warn { background: var(--warn-bg); color: var(--warn-ink); }
.chip--off { background: #eceae4; color: #4f5666; }
.chip--danger { background: var(--danger-bg); color: var(--danger-ink); }
.chip--info { background: var(--info-bg); color: var(--info-ink); }

/* ── 안내 박스 ── */
.callout { display: flex; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: 14px; background: var(--info-bg); color: var(--info-ink); align-items: flex-start; }
.callout .icon { margin-top: 2px; }
.callout__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.callout__title { font-weight: 800; }
.callout__text { font-size: var(--fs-s); color: inherit; }
.callout--warn { background: var(--warn-bg); color: var(--warn-ink); }
.callout--danger { background: var(--danger-bg); color: var(--danger-ink); }
.callout--ok { background: var(--success-bg); color: var(--success-ink); }

/* ── 토스트 ── */
.toast-region { position: fixed; left: 0; right: 0; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 300; display: flex; flex-direction: column; align-items: center; gap: var(--s-2); padding: 0 var(--gutter); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: var(--s-3); max-width: 480px; width: 100%; padding: 12px 14px 12px 16px; border-radius: 16px; background: #222a3a; color: #fff; box-shadow: var(--shadow-2); font-weight: 600; animation: pop-in .22s var(--ease); }
.toast__icon { color: var(--success-solid); display: grid; }
.toast--error .toast__icon { color: #ff8f84; }
.toast--warn .toast__icon { color: var(--warn); }
.toast__text { flex: 1 1 auto; min-width: 0; }
.toast__close { all: unset; cursor: pointer; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; flex: none; }
.toast__close:hover { background: rgba(255,255,255,.14); }
.toast__close:focus-visible { box-shadow: 0 0 0 3px #fff; }
.toast.is-leaving { opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }

/* ── 모달 / 바텀시트 ── */
.modal-backdrop { position: fixed; inset: 0; z-index: 250; background: rgba(28, 34, 48, .5); display: flex; align-items: flex-end; justify-content: center; animation: fade-in .18s var(--ease); }
.modal { background: var(--surface); width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; border-radius: 24px 24px 0 0; padding: var(--s-5) var(--s-4) calc(var(--s-4) + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: var(--s-4); box-shadow: var(--shadow-2); animation: sheet-up .26s var(--ease); position: relative; }
.modal::before { content: ''; align-self: center; width: 40px; height: 5px; border-radius: 3px; background: var(--line-strong); margin-top: -12px; }
.modal__head { display: flex; align-items: center; gap: var(--s-3); }
.modal__title { flex: 1 1 auto; font-size: var(--fs-l); font-weight: 800; }
.modal__body { color: var(--ink-2); display: flex; flex-direction: column; gap: var(--s-3); }
.modal__actions { display: flex; flex-direction: column-reverse; gap: var(--s-3); }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: var(--s-5); }
  .modal { border-radius: 24px; padding-bottom: var(--s-5); animation: pop-in .22s var(--ease); }
  .modal::before { display: none; }
  .modal__actions { flex-direction: row; justify-content: flex-end; }
  .modal__actions > .btn { min-width: 120px; }
}

/* ── 빈 화면 ── */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s-3); padding: var(--s-6) var(--s-4); }
.empty__title { font-size: var(--fs-l); font-weight: 800; }
.empty__text { color: var(--muted); max-width: 32ch; }

/* ── 스켈레톤 ── */
.skeleton { display: block; border-radius: 10px; background: linear-gradient(90deg, var(--surface-2) 25%, #fbf9f4 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.skeleton--line { height: 16px; width: 100%; }
.skeleton--short { width: 55%; }
.skeleton--title { height: 24px; width: 40%; }
.skeleton--block { height: 88px; border-radius: var(--r-card); }
.skeleton--circle { width: 44px; height: 44px; border-radius: 14px; }

/* ── 입력 ── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-weight: 700; }
.field__hint { font-size: var(--fs-s); color: var(--muted); }
.field__error { font-size: var(--fs-s); color: var(--danger-ink); font-weight: 600; display: flex; gap: 6px; align-items: center; }
.input, .select, .textarea {
  width: 100%; min-height: var(--tap); padding: 10px 14px; background: var(--surface); border: 2px solid var(--line-strong); border-radius: var(--r-ctrl);
  font-size: 16px; /* iOS 확대 방지 */ color: var(--ink); transition: border-color var(--dur) var(--ease);
}
.textarea { min-height: 112px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 40px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
.input::placeholder, .textarea::placeholder { color: #7b8394; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-2); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); border-radius: var(--r-ctrl); }
.field[data-invalid="true"] .input, .field[data-invalid="true"] .select, .field[data-invalid="true"] .textarea { border-color: var(--danger); }
.input:disabled { background: var(--surface-2); color: var(--muted); }
.input--code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; font-size: 20px; text-align: center; }

/* ── 복사 줄 ── */
.copy-row { display: flex; align-items: stretch; gap: var(--s-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-ctrl); padding: 6px 6px 6px 14px; }
.copy-row__main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.copy-row__label { font-size: 12px; color: var(--muted); font-weight: 600; line-height: 1.3; }
.copy-row__value { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; word-break: break-all; line-height: 1.4; user-select: all; }
.copy-row .btn { align-self: center; flex: none; }

/* ── QR 틀 ── */
.qr-frame { position: relative; width: 224px; max-width: 100%; aspect-ratio: 1; padding: 18px; background: #fff; border-radius: 20px; box-shadow: var(--shadow-1); border: 1px solid var(--line); display: grid; place-items: center; margin: 0 auto; }
.qr-frame > img, .qr-frame > canvas, .qr-frame > svg { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.qr-frame__corner { position: absolute; width: 26px; height: 26px; border: 4px solid var(--primary); }
.qr-frame__corner--tl { top: -2px; left: -2px; border-right: 0; border-bottom: 0; border-top-left-radius: 20px; }
.qr-frame__corner--tr { top: -2px; right: -2px; border-left: 0; border-bottom: 0; border-top-right-radius: 20px; }
.qr-frame__corner--bl { bottom: -2px; left: -2px; border-right: 0; border-top: 0; border-bottom-left-radius: 20px; }
.qr-frame__corner--br { bottom: -2px; right: -2px; border-left: 0; border-top: 0; border-bottom-right-radius: 20px; }
.qr-frame__empty { color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: var(--s-2); font-size: var(--fs-s); text-align: center; }
.qr-caption { text-align: center; color: var(--muted); font-size: var(--fs-s); margin-top: var(--s-3); }

/* ── 목록 줄 ── */
.list { display: flex; flex-direction: column; gap: var(--s-2); }
.list-row {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; min-height: 64px; padding: var(--s-3) var(--s-4);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); text-align: left; text-decoration: none; color: inherit; box-shadow: var(--shadow-1);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
a.list-row:hover, button.list-row:hover { border-color: var(--primary); background: #F4FAF8; }
.list-row:focus-visible { box-shadow: var(--focus-ring); border-radius: var(--r-card); }
.list-row__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.list-row__title { font-weight: 700; line-height: 1.4; }
.list-row__desc { font-size: var(--fs-s); color: var(--muted); line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row__side { flex: none; display: flex; align-items: center; gap: var(--s-2); color: var(--muted); }
.list-row__chev { color: var(--muted); }
.btn.is-loading:disabled, .btn.is-loading[aria-disabled="true"] { opacity: .85; }
.funnel__track, .funnel__fill, .funnel__value, .funnel__label { display: block; } .funnel__value { white-space: nowrap; }
