@font-face {
  font-family: 'Pretendard';
  src: url('/fonts/pretendard/Pretendard-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Pretendard';
  src: url('/fonts/pretendard/Pretendard-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Pretendard';
  src: url('/fonts/pretendard/Pretendard-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Pretendard';
  src: url('/fonts/pretendard/Pretendard-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Pretendard';
  src: url('/fonts/pretendard/Pretendard-ExtraBold.woff2') format('woff2');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f9fafb;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --primary: #3182f6;
  --primary-strong: #2563eb;
  --primary-soft: rgba(49, 130, 246, 0.08);
  --danger: #ef4444;
  --radius-card: 20px;
  --radius-input: 12px;
  --radius-btn: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo',
    'Noto Sans KR', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  color: var(--text);
  /* 메인 페이지와 동일한 배경 그라디언트 */
  background: radial-gradient(ellipse 120% 80% at 10% 0%, #dbeafe 0%, #f0f6ff 30%, #fafbff 60%, #e8f0fe 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  justify-content: center;
}

/* ── 상단 헤더 ────────────────────────────── */
.visly-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* pt-4(16px) pb-3(12px) px-4(16px) — PageHeader와 동일 */
  padding: 16px 16px 12px;
  background: rgba(249, 250, 251, 0.80);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  /* border-gray-200/60 — PageHeader와 동일 */
  border-bottom: 1px solid rgba(229, 231, 235, 0.6);
}

.visly-header__title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.875rem;
  font-weight: 600;
  color: #1f2937;
  white-space: nowrap;
  pointer-events: none;
}

.visly-header__btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* rounded-xl(12px) — PageHeader와 동일 */
  border-radius: 12px;
  border: none;
  background: transparent;
  /* text-gray-500 — PageHeader와 동일 */
  color: #6b7280;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.visly-header__btn:hover {
  background: #f3f4f6;
  /* hover:text-gray-900 — PageHeader와 동일 */
  color: #111827;
}

.visly-header__right {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── 레이아웃 ────────────────────────────── */
/* ── 언어 전환 슬라이드 애니메이션 (비자 백과사전 framer-motion y:12→0 동일 효과) ── */
@keyframes vislyPageEnter {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-shell {
  width: 100%;
  min-height: 100vh;
  background: var(--bg);
  /* 최초 진입 및 언어 전환 시 재트리거됨 (i18n.js에서 animation 일시 제거 후 복원) */
  animation: vislyPageEnter 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.app-shell {
  min-height: 100vh;
}

.stage {
  display: none;
  min-height: calc(100vh - 57px);
  padding: 20px 20px 120px;
  flex-direction: column;
}

.stage--active {
  display: flex;
}

/* ── 히어로 (1단계) ─────────────────────── */
.hero {
  padding-top: 28px;
  padding-bottom: 4px;
}

.hero h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.03em;
  color: var(--text);
}

.hero__description {
  display: none;
}

/* ── 패널 ────────────────────────────────── */
.panel {
  padding-top: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.panel--success {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── 페이지 헤더 (2~5단계) ─────────────── */
.page-header {
  margin-bottom: 20px;
}

.stage-title {
  margin: 0 0 14px;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.03em;
  color: var(--text);
}

/* ── 진행 카드 ──────────────────────────── */
.progress-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.progress-card__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.progress-card__meta strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.progress-card__meta span {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

.progress-bar {
  height: 5px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--primary);
  transition: width 200ms ease;
}

/* ── 섹션 헤딩 ──────────────────────────── */
.section-heading {
  margin-bottom: 16px;
}

.section-heading h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-heading p {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

/* ── 신청 유형 선택 ─────────────────────── */
.application-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 16px;
}

.application-card {
  width: 100%;
  min-height: 56px;
  padding: 0 18px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: border-color 160ms, background 160ms, transform 160ms, box-shadow 160ms;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.application-card:hover,
.application-card:focus-visible {
  border-color: rgba(49, 130, 246, 0.4);
  background: rgba(49, 130, 246, 0.03);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(49, 130, 246, 0.1);
  outline: none;
}

.application-card.is-selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(49, 130, 246, 0.12);
}

.application-card strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.application-card.is-selected strong {
  color: var(--primary);
}

.application-card span:last-child {
  display: none;
}

/* ── 폼 ─────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-top: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

.field.is-hidden {
  display: none;
}

.field > span,
.signature-section__header strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.required-mark {
  color: var(--danger);
  font-style: normal;
}

.conditional-required {
  display: none;
}

.conditional-required.is-visible {
  display: inline;
}

.field input,
.field select {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-input);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  appearance: none;
  transition: border-color 150ms, box-shadow 150ms;
}

.field input[type="date"] {
  appearance: auto;
}

.field select {
  background-image:
    linear-gradient(45deg, transparent 50%, #9ca3af 50%),
    linear-gradient(135deg, #9ca3af 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 2px),
    calc(100% - 10px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(49, 130, 246, 0.12);
}

.field input.is-invalid,
.field select.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.field-hint {
  font-size: 12px;
  color: #9ca3af;
}

.field-error {
  min-height: 16px;
  font-size: 12px;
  color: var(--danger);
  line-height: 1.4;
}

/* ── 분할 입력 ──────────────────────────── */
.split-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.split-input-group input {
  height: 48px;
  padding: 0;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-input);
  background: var(--surface);
  text-align: center;
  font: inherit;
  font-size: 15px;
  transition: border-color 150ms, box-shadow 150ms;
}

.split-input-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(49, 130, 246, 0.12);
}

.split-input-group--birthdate input {
  flex: 1;
}

.split-input-group--registration {
  gap: 4px;
  flex-wrap: nowrap;
  width: 100%;
}

.split-input-group--registration input {
  flex: 1;
  min-width: 0;
  padding: 0;
  font-size: 13px;
}

.split-input-group__dash {
  color: var(--muted);
  font-weight: 700;
}

/* ── 세그먼트 컨트롤 ─────────────────────── */
.segmented-control {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.segmented-control__button {
  min-height: 44px;
  padding: 0 20px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 150ms, background 150ms, color 150ms;
}

.segmented-control__button.is-selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

/* ── 미리보기 ────────────────────────────── */
.preview-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 16px;
}

.preview-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.preview-card > strong {
  display: block;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.preview-list {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px 12px;
  margin: 0;
}

.preview-list dt {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.preview-list dd {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  color: var(--text);
}

/* ── 서명 ────────────────────────────────── */
.signature-section {
  margin-top: 16px;
}

.signature-section__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

#signature-pad {
  width: 100%;
  min-height: 180px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
  touch-action: none;
  display: block;
}

/* ── 동의 박스 ──────────────────────────── */
.consent-box {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.debug-toggle-box {
  margin-top: 12px;
}

.consent-box input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin: 2px 0 0;
  border: 1.5px solid var(--line-strong);
  border-radius: 5px;
  cursor: pointer;
  accent-color: var(--primary);
}

.consent-box__content {
  display: grid;
  gap: 8px;
}

.consent-box__content strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.consent-list {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.consent-list li {
  position: relative;
  padding-left: 10px;
}

.consent-list li::before {
  content: "·";
  position: absolute;
  left: 0;
}

.consent-list li + li {
  margin-top: 6px;
}

/* ── 알림 ────────────────────────────────── */
.form-alert {
  display: none;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fef2f2;
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(239, 68, 68, 0.15);
}

.form-alert.is-visible {
  display: block;
}

/* ── CTA 버튼 행 ─────────────────────────── */
.cta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: auto; /* flex panel 최하단 밀어내기 */
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(420px, 100vw);
  padding: 14px 20px 28px;
  background: linear-gradient(180deg, rgba(249, 250, 251, 0) 0%, #f9fafb 30%);
  z-index: 20;
}

.cta-row--end {
  grid-template-columns: 1fr;
}

/* ── 버튼 ────────────────────────────────── */
.button,
.text-button {
  font: inherit;
  cursor: pointer;
}

.button {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: var(--radius-btn);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: background 150ms, transform 100ms, box-shadow 150ms;
}

.button:active {
  transform: scale(0.98);
}

.button--primary {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 2px 10px rgba(49, 130, 246, 0.3);
}

.button--primary:hover {
  background: var(--primary-strong);
  box-shadow: 0 4px 14px rgba(49, 130, 246, 0.35);
}

.button--ghost {
  color: var(--muted);
  background: var(--line);
  border: 1px solid var(--line-strong);
}

.button--ghost:hover {
  background: #e5e7eb;
}

.text-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
}

.text-button:hover {
  opacity: 0.75;
}

/* ── 성공 화면 ──────────────────────────── */
.panel--success .section-heading h2 {
  font-size: 20px;
}

/* ── 태블릿/데스크탑 레이아웃 ────────────── */
@media (min-width: 600px) {
  body {
    /* 비자 백과사전(PageShell)과 동일: 상하 24px, 좌우 패딩 없음 */
    padding: 24px 0;
    align-items: flex-start;
  }

  .page-shell {
    width: 100%;
    max-width: 672px;
    min-height: calc(100vh - 48px);
    border-radius: 20px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05), 0 8px 32px rgba(0, 0, 0, 0.08);
    /* overflow: clip → rounded corner clip without blocking sticky */
    overflow: clip;
  }

  /* app-shell: 스테이지가 높이를 결정하므로 auto로 */
  .app-shell {
    min-height: auto;
  }

  /* 스테이지 — body padding(48px) + header(57px) 뺀 나머지 채움 */
  .stage {
    padding: 28px 36px 0;
    min-height: calc(100vh - 105px);
  }

  /* 스크롤 여백 — CTA 자체 padding-bottom으로 처리, stage는 0 */
  .stage--active {
    padding-bottom: 0;
  }

  /* 히어로 */
  .hero {
    padding-top: 20px;
  }

  .hero h1,
  .stage-title {
    font-size: 26px;
  }

  /* 신청 유형 선택 — 2열 그리드 */
  .application-grid {
    grid-template-columns: 1fr 1fr;
    margin-top: 20px;
  }

  /* 폼 — 2열 그리드 */
  .form-grid {
    grid-template-columns: 1fr 1fr;
    gap: 24px 28px;
    margin-top: 24px;
  }

  /* 전체 너비 필드 */
  .field--full {
    grid-column: 1 / -1;
  }

  /* 미리보기 2열 */
  .preview-grid {
    grid-template-columns: 1fr 1fr;
  }

  #preview-workplace-card {
    grid-column: 1 / -1;
  }

  /* 진행 카드 가로 배치 */
  .progress-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 20px;
  }

  .progress-card__meta {
    margin-bottom: 0;
    min-width: 180px;
    flex-shrink: 0;
  }

  .progress-bar {
    flex: 1;
  }

  /* CTA 버튼 — 레이어 최하단 sticky */
  .cta-row {
    position: sticky;
    bottom: 0;
    left: auto;
    transform: none;
    width: 100%;
    padding: 20px 0 36px; /* 좌우 마진(36px)과 동일하게 */
    background: linear-gradient(180deg, rgba(249, 250, 251, 0) 0%, #f9fafb 40%);
    max-width: none;
    margin-top: auto; /* panel flex 최하단 밀어내기 */
    z-index: 20;
  }

  .cta-row--end {
    max-width: none;
  }

  .button {
    min-height: 48px;
    border-radius: 12px;
    font-size: 14px;
  }

  /* 서명 패드 */
  #signature-pad {
    min-height: 200px;
  }

  /* 외국인 등록번호 — 데스크탑에서 더 크게 */
  .split-input-group--registration input {
    font-size: 15px;
    height: 52px;
  }
}

@media (min-width: 900px) {
  body {
    padding: 24px 0;
  }
}
