.sheet-head:has(.sheet-back),.context-panel-head:has(.sheet-back){gap:8px}.sheet-back{display:inline-flex;align-items:center;gap:2px;flex-shrink:0;min-height:44px;padding:6px 8px 6px 0;color:var(--accent-ink);font:inherit;font-size:14px;white-space:nowrap}.sheet-back .icon{width:20px;height:20px}.sheet-head:has(.sheet-back) h2,.context-panel-head:has(.sheet-back) h2{flex:1;min-width:0;font-size:18px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.sheet-back:disabled{opacity:.5}

/* 채팅은 팝업이 아니라 전체 화면 페이지다(2026-11-06 확정). 하단 탭은 최상위 레이어의 대화 페이지가 덮어 보이지 않고, 입력창은 아래에 붙는다. */
#sheet.han-popup.chat-page{inset:0;margin:0;width:100%;max-width:none;height:100dvh;max-height:none;padding:0;border:0;border-radius:0;box-shadow:none;overflow:hidden;background:#fff}
#sheet.han-popup.chat-page[open]{display:flex;flex-direction:column}
#sheet.chat-page::backdrop{background:#fff;backdrop-filter:none}
#sheet.han-popup.chat-page .sheet-head{flex:none;padding-top:max(8px,env(safe-area-inset-top));border-bottom:1px solid var(--line);background:#fff}
#sheet.chat-page .sheet-head [data-action="close"]{display:none}
#sheet.chat-page .sheet-back{color:var(--ink)}
#sheet.han-popup.chat-page #sheet-body{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;display:flex;flex-direction:column;padding:16px max(16px,calc((100% - 720px) / 2)) 0}
#sheet.chat-page #sheet-body>*{flex:none}
#sheet.chat-page #sheet-body>.social-view{flex:1 0 auto;display:flex;flex-direction:column}
#sheet.chat-page .shared-chat-body{height:auto;min-height:120px;max-height:none;overflow:visible;flex:1 0 auto}
#sheet.chat-page .message-form{position:sticky;bottom:0;z-index:2;margin-top:auto;padding:8px 0 calc(8px + env(safe-area-inset-bottom));background:#fff}
#sheet.chat-page,#sheet.chat-page:focus-visible{outline:none}

/* 채팅 페이지 상단 바: 대화 상대(모임은 모임 이름)를 화면 가운데에 크고 진하게, 왼쪽 '뒤로'와 같은 줄·같은 높이. 좌우 칸 폭을 같게(1fr auto 1fr) 잡아 오른쪽 버튼이 없어도 정가운데. */
#sheet.han-popup.chat-page .sheet-head{display:grid;grid-template-columns:minmax(92px,1fr) minmax(0,auto) minmax(92px,1fr);align-items:center;gap:8px;min-height:54px;padding:max(8px,env(safe-area-inset-top)) 12px 8px}
#sheet.chat-page .sheet-head .sheet-back{grid-column:1;justify-self:start}
#sheet.han-popup.chat-page #sheet-title{grid-column:2;grid-row:1;min-width:0;max-width:100%;margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center;color:var(--ink);font-size:var(--text-section);font-weight:var(--w-bold);line-height:var(--lh-section)}

/* 4d: 대화 페이지 상단 바 오른쪽 아이콘(알림·나가기·차단·⋯)과 이름 링크, 대화 첫머리 시스템 안내 */
#sheet.chat-page .chat-head-actions{grid-column:3;grid-row:1;justify-self:end;display:flex;align-items:center;gap:0}
#sheet.chat-page .chat-head-btn,#sheet.chat-page .chat-head-actions .action-menu>summary{width:44px;height:44px;min-height:44px;display:grid;place-items:center;border-radius:50%;color:var(--ink)}
#sheet.chat-page .chat-head-btn[aria-pressed="false"]{color:var(--muted)}
#sheet.chat-page .chat-head-actions .action-menu{margin:0}
#sheet.chat-page .chat-title-link{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font:inherit;color:inherit;padding:8px 4px;min-height:44px}
#sheet.chat-page .chat-system-note{margin:4px auto 12px;max-width:34em;text-align:center;font-size:var(--text-meta);line-height:var(--lh-meta);color:var(--muted)}
#sheet.chat-page [data-trade-completion]{margin:4px auto 12px;padding:0;border:0;background:none;text-align:center;font-size:var(--text-meta);color:var(--muted);box-shadow:none}
#sheet.chat-page [data-trade-completion] p{margin:0 0 4px;font-size:inherit;color:inherit}
#sheet.chat-page [data-trade-completion] button{min-height:44px;font-size:inherit;color:var(--accent-ink);background:none;border:0;padding:0 12px;box-shadow:none}
/* 2026-11-08 입력이 많은 신청·등록·검토 화면 = 전체 화면 페이지(.form-page). 글은 위에서부터, 주 버튼은 화면 아래 붙고 브랜드 빨강 */
#sheet.han-popup.chat-page.form-page #sheet-body{display:block;padding:16px max(16px,calc((100% - 640px) / 2)) calc(24px + env(safe-area-inset-bottom))}
#sheet.form-page #sheet-body form>.primary:last-of-type,#sheet.form-page #sheet-body form>button.primary.full{position:sticky;bottom:calc(8px + env(safe-area-inset-bottom));z-index:2;width:100%;min-height:52px;margin-top:20px;border-color:var(--primary);background:var(--primary);color:#fff;box-shadow:0 -14px 18px 2px #fff}
#sheet.form-page #sheet-body input,#sheet.form-page #sheet-body select,#sheet.form-page #sheet-body textarea{width:100%;max-width:100%;min-width:0;box-sizing:border-box}
/* 2026-11-13 필수 칸 검증 말풍선이 아래 붙은 등록 버튼에 가리지 않게: 칸이 버튼 위쪽에서 멈추도록 */
#sheet.form-page #sheet-body :is(input,select,textarea,fieldset,[data-required]){scroll-margin-bottom:calc(120px + env(safe-area-inset-bottom))}
#sheet.han-popup.chat-page.form-page #sheet-body{padding-bottom:calc(48px + env(safe-area-inset-bottom))}
#sheet.form-page .field-note{margin:-6px 0 0}
/* 관리자 검토: 위쪽 탭에 건수, 키워드 관리는 오른쪽 위 작은 버튼, 안내 한 줄 */
#sheet.form-page .mod-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:0 0 8px}
#sheet.form-page .mod-head .fieldhelp{margin:0;min-width:0}
#sheet.form-page .mod-keyword{flex:none;min-height:44px;padding:0 4px;font-size:var(--text-meta)}
.mod-tabs{display:flex;gap:6px;overflow-x:auto;scrollbar-width:none;margin:0 -16px 12px;padding:0 16px 2px;border-bottom:1px solid var(--line)}
.mod-tabs::-webkit-scrollbar{display:none}
.mod-tab{flex:none;min-height:44px;padding:0 10px;border:0;border-bottom:2px solid transparent;background:none;font-size:var(--text-control);color:var(--muted);white-space:nowrap}
.mod-tab[aria-selected="true"]{color:var(--ink);font-weight:var(--w-strong);border-bottom-color:var(--ink)}
.mod-count{font-variant-numeric:tabular-nums;color:var(--muted);font-weight:var(--w-regular)}
.mod-tab[aria-selected="true"] .mod-count{color:var(--primary);font-weight:var(--w-strong)}
.mod-empty{margin:12px 0}
/* 2026-11-08 짧은 선택만 하는 창(글 종류·연결 종류·가게 정보 알리기 고르기)은 휴대폰에서 화면 아래 붙은 시트 */
@media(max-width:767px){
 #sheet.han-popup.bottom-sheet{inset:auto 0 0 0;margin:0 auto;width:100%;max-width:520px;height:auto;max-height:85dvh;border-radius:var(--radius-card) var(--radius-card) 0 0;padding-bottom:env(safe-area-inset-bottom)}
 #sheet.han-popup.bottom-sheet[open]{animation:han-sheet-up .2s ease-out}
}
@keyframes han-sheet-up{from{transform:translateY(24px);opacity:.6}to{transform:none;opacity:1}}
@media(prefers-reduced-motion:reduce){#sheet.han-popup.bottom-sheet[open]{animation:none}}
/* 입력 화면을 닫기 전 확인(2026-11-08 검토 P3①): 화면 아래에 붙은 한 줄 묻기 */
#sheet .leave-ask{position:sticky;bottom:0;z-index:5;display:grid;gap:10px;margin:0;padding:14px 16px calc(14px + env(safe-area-inset-bottom));background:#fff;border-top:1px solid var(--line);box-shadow:0 -10px 24px #17191f14}
#sheet .leave-ask p{margin:0;font-size:var(--text-meta);color:var(--ink)}
#sheet .leave-ask>div{display:grid;grid-template-columns:1fr 1fr;gap:8px}
#sheet .leave-ask button{min-height:48px}
/* 나가기는 빨강 강조 없이 보조 버튼, 그대로 머무는 '계속 쓰기'를 기본 버튼으로(2026-11-09 검토 P3) */
#sheet.chat-page .leave-ask{position:absolute;left:0;right:0;bottom:0}
/* 2026-11-09 입력이 있는 아래 시트는 화면 높이 92%까지(스크롤 거의 없이), 글 내용 칸은 3줄 높이부터 */
@media(max-width:767px){
 #sheet.han-popup.bottom-sheet:has(form){max-height:92dvh}
 #sheet.bottom-sheet #compose-form textarea[name="body"]{min-height:96px}
 /* 글쓰기는 입력하며 안내 한 줄이 생겨도 칸이 위로 밀리지 않게 높이 고정 */
 #sheet.han-popup.bottom-sheet:has(#compose-form){height:92dvh}
}
/* 관심 도시·생활 단계도 전체 화면이면 화면 높이 전체, 저장 버튼은 빨강 */
#sheet.han-popup.form-page[open]:has(#cities-form){height:100dvh;max-height:none}
#sheet.form-page .city-settings-footer>.primary:not(:disabled){background:var(--primary);border-color:var(--primary);color:#fff}
/* 입력 화면(전체 화면) 제목은 잘리지 않게 두 줄까지(오른쪽 칸은 비어 있어 좁게) — 예: '관심 도시·생활 단계' 320·1.8배 */
#sheet.han-popup.chat-page.form-page .sheet-head{grid-template-columns:minmax(72px,auto) minmax(0,1fr) minmax(16px,72px)}
#sheet.han-popup.chat-page.form-page #sheet-title{white-space:normal;text-overflow:clip;overflow:visible;line-height:1.25;overflow-wrap:anywhere;word-break:keep-all}

/* 2026-11-09 사용자 지적: 전체 화면 페이지에서 뒤로가기가 안 보이는 일이 없게. 뒤로 버튼이 없으면 닫기 버튼을 왼쪽에 보인다 */
#sheet.chat-page .sheet-head:not(:has([data-sheet-back])) [data-action="close"]{display:inline-flex;grid-column:1;grid-row:1;justify-self:start}
#sheet.chat-page.market-compose-popup .sheet-head .sheet-back{grid-column:1;grid-row:1;justify-self:start}
/* 모임 대화방이 닫히면 입력창 자리에 회색 한 줄(아래가 비지 않게) */
.chat-closed-line{margin:12px 0 0;padding:14px 8px;text-align:center;font-size:var(--text-meta);line-height:var(--lh-meta);color:var(--muted)}
#sheet.chat-page .chat-closed-line{position:sticky;bottom:0;z-index:2;margin:auto 0 0;padding:14px 8px calc(14px + env(safe-area-inset-bottom));background:#fff;border-top:1px solid var(--line)}
