/* ==========================================================================
   외인9단 (9dan) — 앱 화면 웹 구현
   9dan.css 의 토큰을 그대로 쓰고, 모바일(402×874) 셸 컴포넌트만 추가한다.
   출처: Claude Design "9dan Screens" 의 IOSDevice 프레임 화면
   ========================================================================== */

:root {
  --dev-w: 402px;          /* 시안 기준 기기 너비 */
  --dev-h: 874px;
  --status-h: 54px;        /* 상태바 */
  --pad: 20px;             /* 좌우 기본 여백 */
  --safe-bottom: 26px;     /* 홈 인디케이터 영역 */
}

/* --------------------------------------------------------------------------
   1. 기기 프레임
   데스크탑: 402×874 프레임을 가운데 두고 캔버스처럼 보여준다.
   실제 모바일(≤430px): 프레임을 벗고 전체 화면으로 동작한다.
   -------------------------------------------------------------------------- */
body.app-page {
  background: #E7ECF3;
  display: flex; flex-direction: column; align-items: center;
  padding: 40px 20px;
  min-height: 100vh;
}

.device {
  width: var(--dev-w); height: var(--dev-h);
  flex: none;
  border-radius: 44px;
  background: var(--surface);
  box-shadow: 0 0 0 10px #10151D, 0 0 0 12px #2A323E, 0 30px 70px rgba(15, 23, 36, .28);
  overflow: hidden;
  position: relative;
}

/* 노치 */
.device::before {
  content: '';
  position: absolute; top: 11px; left: 50%; transform: translateX(-50%);
  width: 124px; height: 32px; border-radius: 999px; background: #10151D;
  z-index: 30;
}

/* 홈 인디케이터 */
.device::after {
  content: '';
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  width: 138px; height: 5px; border-radius: 999px; background: rgba(22, 32, 46, .32);
  z-index: 30; pointer-events: none;
}
.device.is-dark::after { background: rgba(255, 255, 255, .5); }

.app {
  height: 100%; width: 100%;
  display: flex; flex-direction: column;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
.app--white { background: var(--surface); }

/* 상태바 */
.app-status {
  height: var(--status-h); flex: none;
  padding: 0 32px; padding-top: 12px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px; font-weight: 700; letter-spacing: -0.01em;
  color: var(--ink);
  position: relative; z-index: 20;
}
.app-status__icons { display: flex; align-items: center; gap: 5px; }
.app-status--light, .app-status--light * { color: #fff; }

/* 스크롤 본문 */
.app-body {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.app-body--pad { padding: 16px var(--pad); display: flex; flex-direction: column; gap: 14px; }

/* --------------------------------------------------------------------------
   2. 앱바
   -------------------------------------------------------------------------- */
.app-bar {
  flex: none; background: var(--surface);
  padding: 6px var(--pad) 8px;
  display: flex; align-items: center; gap: 12px;
}
.app-bar__title { font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }
.app-bar__sub   { font-size: 11.5px; color: var(--ink-3); }
.app-bar--line  { border-bottom: 1px solid var(--line-2); }
.app-bar--plain { background: none; }

/* 큰 제목 (탭 루트) */
.app-bar--large {
  padding: 8px var(--pad) 10px;
  justify-content: space-between; background: none;
}
.app-bar--large .app-bar__title { font-size: 23px; font-weight: 800; letter-spacing: -0.02em; }

.app-back {
  display: grid; place-items: center; flex: none;
  width: 24px; height: 24px; margin-left: -4px;
  background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink);
}

.icon-btn {
  position: relative; display: grid; place-items: center; flex: none;
  width: 38px; height: 38px; border-radius: var(--r-full);
  background: var(--surface); border: 1px solid var(--line);
  cursor: pointer; color: var(--ink-2);
}
.icon-btn--flat { background: var(--surface-2); border-color: transparent; }
.icon-btn__dot {
  position: absolute; top: 6px; right: 7px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); border: 1.5px solid var(--bg);
}

/* --------------------------------------------------------------------------
   3. 하단 탭 바
   -------------------------------------------------------------------------- */
.app-tabs {
  flex: none;
  display: flex; justify-content: space-around;
  padding: 10px 8px var(--safe-bottom);
  border-top: 1px solid var(--line); background: var(--surface);
}
.app-tabs a {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; color: var(--ink-3);
  padding: 2px 10px;
}
.app-tabs a:hover { text-decoration: none; }
.app-tabs a[aria-current="page"] { color: var(--blue-strong); font-weight: 700; }

/* 하단 고정 CTA */
.app-cta {
  flex: none; padding: 12px var(--pad) 34px;
  border-top: 1px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; gap: 10px;
}
.app-cta--plain { background: var(--bg); border-top: 0; }

.btn-app {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 54px; border-radius: 14px;
  font-size: 16px; font-weight: 700; line-height: 1;
  border: 0; background: var(--blue); color: #fff;
  cursor: pointer; width: 100%;
}
.btn-app--outline { background: none; border: 1.5px solid var(--blue); color: var(--blue-strong); }
.btn-app--ghost   { background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); }
.btn-app--danger  { background: var(--surface); border: 1px solid var(--line); color: var(--danger-2); height: 50px; border-radius: 13px; font-size: 15px; }
.btn-app--sm      { height: 46px; border-radius: 12px; font-size: 14.5px; }

/* --------------------------------------------------------------------------
   4. 바텀시트
   -------------------------------------------------------------------------- */
.sheet-host { position: absolute; inset: 0; z-index: 25; display: flex; flex-direction: column; justify-content: flex-end; }
.sheet-host[hidden] { display: none; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(15, 23, 36, .45); border: 0; padding: 0; cursor: pointer; }
.sheet {
  position: relative;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 10px var(--pad) 40px;
  display: flex; flex-direction: column; gap: 18px;
  box-shadow: 0 -12px 40px rgba(15, 23, 36, .18);
  max-height: 88%; overflow-y: auto;
}
.sheet__grab { width: 38px; height: 5px; border-radius: var(--r-full); background: var(--line-3); margin: 0 auto; flex: none; }
.sheet__title { font-size: 19px; font-weight: 800; }

/* 시트 뒤에 깔리는 흐린 배경 화면 */
.app-dim { opacity: .5; }

/* --------------------------------------------------------------------------
   5. 리스트 · 세그먼트 · 스위치
   -------------------------------------------------------------------------- */
/* 밑줄 탭 (스크랩 5 / 최근 본 12) */
.utabs {
  display: flex; gap: 6px; flex: none;
  padding: 10px var(--pad) 0;
  background: var(--surface); border-bottom: 1px solid var(--line-2);
}
.utabs button {
  border: 0; background: none; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--ink-3);
  padding: 9px 14px; border-bottom: 2.5px solid transparent;
}
.utabs button[aria-selected="true"] { color: var(--blue-strong); font-weight: 700; border-bottom-color: var(--blue); }

/* 셀 리스트 (그룹 카드) */
.cells {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-14); overflow: hidden;
}
.cell {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; color: inherit;
}
.cell + .cell { border-top: 1px solid var(--line-2); }
.cell:hover { text-decoration: none; background: var(--bg); }
.cell__main { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cell__title { font-size: 14.5px; font-weight: 600; }
.cell__sub   { font-size: 12px; color: var(--ink-3); }
.chev { flex: none; }

/* 스위치 */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  display: block; width: 100%; height: 100%;
  border-radius: var(--r-full); background: var(--line-3);
  transition: background-color .18s;
}
.switch__track::after {
  content: ''; position: absolute; top: 2.5px; left: 2.5px;
  width: 21px; height: 21px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  transition: transform .18s;
}
.switch input:checked + .switch__track { background: var(--blue); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--blue); outline-offset: 2px; }

/* 섹션 구분 (두꺼운 회색 띠) */
.band { border-bottom: 8px solid var(--surface-2); }

/* FAB */
.fab {
  position: absolute; right: var(--pad); bottom: 112px; z-index: 15;
  width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: var(--blue); color: #fff;
  display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 10px 24px rgba(37, 99, 235, .35);
}

/* --------------------------------------------------------------------------
   6. 화면별 컴포넌트
   -------------------------------------------------------------------------- */
/* 진행 타임라인 (4g) */
.tl { display: flex; flex-direction: column; }
.tl__row { display: flex; gap: 13px; }
.tl__rail { display: flex; flex-direction: column; align-items: center; }
.tl__dot {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: grid; place-items: center; background: var(--blue);
}
.tl__dot--now  { background: var(--warn); box-shadow: 0 0 0 5px var(--warn-bg); }
.tl__dot--todo { background: none; border: 2px solid var(--line-3); box-sizing: border-box; }
.tl__line { width: 2px; flex: 1; background: var(--blue); }
.tl__line--todo { background: var(--line); }
.tl__body { display: flex; flex-direction: column; gap: 2px; padding-bottom: 18px; }
.tl__title { font-size: 14.5px; font-weight: 700; }
.tl__desc  { font-size: 12.5px; color: var(--ink-3); }

/* 채팅 (4h) */
.msg { display: flex; gap: 9px; max-width: 86%; }
.msg__av {
  flex: none; width: 30px; height: 30px; border-radius: 9px;
  background: var(--blue-soft); display: grid; place-items: center;
  font-size: 9px; font-weight: 800; color: var(--blue-strong);
}
.msg__col { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bubble {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 4px 16px 16px 16px;
  padding: 12px 14px; font-size: 14px; line-height: 1.55;
}
.msg__time { font-size: 11px; color: #B9C2CF; }
.msg--me { align-self: flex-end; align-items: flex-end; max-width: 86%; flex-direction: column; gap: 4px; }
.msg--me .bubble {
  background: var(--blue); color: #fff; border-color: var(--blue);
  border-radius: 16px 4px 16px 16px;
}
.chat-input {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 10px var(--pad) 32px;
  background: var(--surface); border-top: 1px solid var(--line-2);
}
.chat-input input {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: var(--r-full);
  padding: 11px 16px; font-size: 14px; outline: none; background: var(--surface);
}
.chat-input input:focus { border-color: var(--blue); }
.chat-send {
  display: grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--blue); border: 0; cursor: pointer;
}

/* 비자 카드 (5c) */
.visa-card {
  background: var(--blue); color: #fff;
  border-radius: var(--r-16); padding: 18px;
  display: flex; flex-direction: column; gap: 8px;
}
.visa-card__k { font-size: 12.5px; font-weight: 700; opacity: .8; }
.visa-card__note {
  font-size: 12.5px; font-weight: 700; text-align: center;
  background: rgba(255, 255, 255, .16); padding: 8px 0; border-radius: 9px; margin-top: 4px;
}

/* 통계 3분할 (4i) */
.stat-row { display: flex; gap: 10px; }
.stat-row > span {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--bg); border-radius: var(--r-12); padding: 12px 0;
}
.stat-row b { font-size: 17px; font-weight: 800; color: var(--blue-strong); }
.stat-row small { font-size: 11.5px; color: var(--ink-3); }

/* 빈 상태 / 오류 (5e) */
.state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  padding: 0 40px; text-align: center;
}
.state__icon { width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.state__icon--info  { background: #EDF2F9; }
.state__icon--error { background: #FDF0EF; }
.state__icon--ok    { background: var(--ok-bg); width: 76px; height: 76px; }
.state__title { font-size: 18px; font-weight: 800; }
.state__desc  { font-size: 14px; color: var(--ink-3); line-height: 1.6; }
.state__code  { font-size: 12.5px; color: #B9C2CF; }

/* 겹친 아바타 (2.1) */
.stack-avatars { display: flex; }
.stack-avatars .avatar { border: 2px solid var(--surface); width: 26px; height: 26px; font-size: 10px; }
.stack-avatars .avatar + .avatar { margin-left: -8px; }

/* 이미지 캐러셀 (1.3) */
.carousel { position: relative; height: 230px; flex: none; }
.carousel .ph { height: 100%; }
.carousel__btn {
  position: absolute; top: 4px; display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: var(--r-full);
  background: rgba(255, 255, 255, .9); border: 0; cursor: pointer; color: var(--ink);
}
.carousel__btn--back  { left: 16px; }
.carousel__btn--share { right: 16px; }
.carousel__dots { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 5px; }
.carousel__dots i { width: 5px; height: 5px; border-radius: 50%; background: rgba(255, 255, 255, .6); }
.carousel__dots i.on { width: 14px; border-radius: var(--r-full); background: #fff; }

/* 선택 가능한 카드 리스트 (0.2 언어 · 1.4 이력서) */
.pick {
  display: flex; align-items: center; gap: 14px;
  border: 1px solid var(--line); border-radius: var(--r-14);
  padding: 17px 18px; cursor: pointer; background: var(--surface);
}
.pick input { position: absolute; opacity: 0; width: 0; height: 0; }
.pick__main { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pick__name { font-size: 16px; font-weight: 700; }
.pick__sub  { font-size: 12px; color: var(--ink-3); }
.pick__check { opacity: 0; flex: none; color: var(--blue); }
.pick__radio { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line-4); background: #fff; flex: none; }
.pick:has(input:checked) { border: 1.5px solid var(--blue); background: var(--blue-tint); }
.pick:has(input:checked) .pick__check { opacity: 1; }
.pick:has(input:checked) .pick__radio { border: 6px solid var(--blue); }
.pick--sm { padding: 14px 15px; border-radius: 13px; }
.pick--sm .pick__name { font-size: 14.5px; }

/* 앱 입력 필드 */
.app-field { display: flex; flex-direction: column; gap: 7px; }
.app-field__label { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.app-input {
  width: 100%; border: 1px solid var(--line); border-radius: 13px;
  padding: 14px 16px; font-size: 15px; background: var(--surface); color: var(--ink);
  outline: none;
}
.app-input::placeholder { color: var(--ink-3); }
.app-input:focus { border-color: var(--blue); }
.app-input--err { border: 1.5px solid var(--danger); }
.app-err { font-size: 12.5px; color: var(--danger-2); line-height: 1.5; }
.app-textarea { min-height: 76px; resize: vertical; line-height: 1.5; }

/* 좌우 분할 선택 (성별) */
.duo { display: flex; gap: 6px; }
.duo label {
  flex: 1; text-align: center; font-size: 14px; font-weight: 600; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: var(--r-11); padding: 13px 0; cursor: pointer;
}
.duo input { position: absolute; opacity: 0; width: 0; height: 0; }
.duo label:has(input:checked) {
  color: var(--blue-strong); font-weight: 700;
  background: var(--blue-soft); border-color: var(--blue-soft-line);
}

/* --------------------------------------------------------------------------
   6b. 명세서 기준 화면용 컴포넌트
       (커뮤니티 3.x · 마이페이지 4.x · 공통 오버레이 C.x)
   -------------------------------------------------------------------------- */

/* C.2 로그인 유도 다이얼로그 */
.dialog-host {
  position: absolute; inset: 0; z-index: 28;
  display: grid; place-items: center; padding: 0 28px;
}
.dialog-host[hidden] { display: none; }
.dialog-scrim { position: absolute; inset: 0; background: rgba(15, 23, 36, .45); border: 0; padding: 0; cursor: pointer; }
.dialog {
  position: relative; width: 100%;
  background: var(--surface); border-radius: 20px;
  padding: 24px 22px 18px;
  display: flex; flex-direction: column; gap: 8px; text-align: center;
  box-shadow: 0 24px 60px rgba(15, 23, 36, .3);
}
.dialog__icon {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 4px;
  background: var(--blue-soft); display: grid; place-items: center;
}
.dialog__title { font-size: 17.5px; font-weight: 800; }
.dialog__desc  { font-size: 13.5px; color: var(--ink-2); line-height: 1.6; }
.dialog__actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

/* 3.2 반응 (좋아요 / 싫어요) */
.reaction {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13.5px; font-weight: 700; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line);
  padding: 9px 16px; border-radius: var(--r-full); cursor: pointer;
}
.reaction[aria-pressed="true"] {
  color: var(--blue-strong); background: var(--blue-soft); border-color: var(--blue-soft-line);
}
.reaction[aria-pressed="true"].reaction--down {
  color: var(--danger-2); background: #FDF0EF; border-color: var(--danger-line);
}

/* 3.2 댓글 · 대댓글(1뎁스) */
.comment { display: flex; gap: 10px; padding: 14px 0; border-top: 1px solid var(--line-2); }
.comment:first-child { border-top: 0; }
.comment--reply { padding-left: 42px; }
.comment__col { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.comment__head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.comment__who { font-size: 13.5px; font-weight: 700; }
.comment__when { font-size: 11.5px; color: var(--ink-3); }
.comment__body { font-size: 13.5px; color: var(--ink-2); line-height: 1.6; }
.comment__acts { display: flex; gap: 12px; font-size: 12px; font-weight: 700; color: var(--ink-3); }
.comment__acts button { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; color: inherit; }

/* 3.3 본문 단락 편집 (bodies[] · orders) */
.para {
  border: 1px solid var(--line); border-radius: 13px;
  background: var(--surface); overflow: hidden;
}
.para__bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; background: var(--bg); border-bottom: 1px solid var(--line-2);
}
.para__kind { font-size: 11.5px; font-weight: 700; color: var(--ink-3); letter-spacing: .04em; }
.para__tools { margin-left: auto; display: flex; gap: 4px; }
.para__tools button {
  width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; display: grid; place-items: center; color: var(--ink-2);
}
.para__tools button:disabled { opacity: .35; cursor: default; }
.para textarea { border: 0; border-radius: 0; }
.para textarea:focus { border: 0; box-shadow: none; }

/* 4.1 프로필 요약 */
.profile {
  background: var(--surface); padding: 14px 20px 20px;
  display: flex; align-items: center; gap: 14px; flex: none;
}
.profile__name { font-size: 19px; font-weight: 800; letter-spacing: -0.01em; }
.profile__sub  { font-size: 13px; color: var(--ink-3); }

/* 4.5 상태 필터 · 알림 미읽음 */
.notif-unread { background: var(--blue-tint); }
.notif-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--blue); flex: none; margin-top: 6px;
}

/* --------------------------------------------------------------------------
   7. 한 페이지에 기기를 여러 대 놓을 때 (5e 빈 상태·오류 세트)
   -------------------------------------------------------------------------- */
.gallery { display: flex; flex-wrap: wrap; gap: 40px; justify-content: center; }
.gallery figure { margin: 0; display: flex; flex-direction: column; gap: 12px; }
.gallery figcaption { display: flex; align-items: center; gap: 10px; }

/* --------------------------------------------------------------------------
   8. 실제 모바일 — 프레임 해제
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  body.app-page { padding: 0; background: var(--surface); display: block; }
  .device {
    width: 100%; height: 100dvh; border-radius: 0; box-shadow: none;
  }
  .device::before { display: none; }
  .device::after { bottom: 4px; }
  .app-status { padding-top: env(safe-area-inset-top, 8px); }
  .app-tabs { padding-bottom: max(var(--safe-bottom), env(safe-area-inset-bottom)); }
}

@media print {
  body.app-page { background: #fff; }
  .device { box-shadow: none; border: 1px solid var(--line); }
}


/* --------------------------------------------------------------------------
   실데이터 연동 공통 (9dan-app.js App.*)
   -------------------------------------------------------------------------- */
.app-toast {
  position: absolute; left: 16px; right: 16px; bottom: 96px; z-index: 40;
  background: #16202E; color: #fff; border-radius: 12px; padding: 13px 16px;
  font-size: 13.5px; font-weight: 600; line-height: 1.45;
  box-shadow: 0 10px 30px rgba(15, 23, 36, .3);
  animation: app-toast-in .18s ease-out;
  transition: opacity .3s, transform .3s;
}
.app-toast.is-out { opacity: 0; transform: translateY(8px); }
@keyframes app-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.sheet-menu { display: flex; flex-direction: column; }
.sheet-menu button {
  background: none; border: 0; border-top: 1px solid var(--line-2); padding: 15px 4px;
  text-align: left; font-size: 15px; font-weight: 600; color: var(--ink); cursor: pointer;
}
.sheet-menu button:first-child { border-top: 0; }
.sheet-menu button.is-danger { color: var(--danger-2); }
.dialog .app-input { width: 100%; box-sizing: border-box; }

.more-btn {
  background: none; border: 0; padding: 4px 6px; cursor: pointer; color: var(--ink-3);
  font-size: 18px; line-height: 1; letter-spacing: 1px; border-radius: 8px;
}
.more-btn:hover { background: var(--surface-2); }
.link-btn { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; font-weight: 700; color: var(--blue-strong); }
.link-btn--danger { color: var(--danger-2); }
.blind-badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700;
  color: var(--danger-2); background: #FDF0EF; padding: 3px 8px; border-radius: var(--r-full);
}
button:disabled.btn-app, .btn-app[aria-disabled="true"] { opacity: .55; cursor: default; }
.badge--red { background: var(--danger-2); color: #fff; }
