/* chat.css — 원본 ChatPage.tsx의 chatStyles·인라인 스타일을 클래스로 옮긴 것(8단계).
   레이아웃: 왼쪽 220px 채널/DM 목록 + 오른쪽 대화(헤더·고정 패널·메시지·컴포저). 768px 이하에서는 한 칸씩. */

.chat-wrap { display: grid; grid-template-columns: 220px 1fr; flex: 1; min-height: 0; overflow: hidden; }

/* ── 왼쪽 목록 ── */
.chat-side { border-right: 1px solid var(--line); padding: 20px 12px; background: var(--bg); display: flex; flex-direction: column; gap: 1px; overflow: auto; }
.chat-side-hd { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 14px; }
.chat-side-hd h2 { font-size: 18px; font-weight: 650; letter-spacing: -.02em; margin: 0; }
.chat-side-sec { font-size: 10.5px; font-weight: 600; color: var(--ink-4); text-transform: uppercase; letter-spacing: .08em; padding: 16px 10px 6px; }
.chat-side-row { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; font-size: 13px; color: var(--ink-2); cursor: default; transition: background .12s; text-decoration: none; }
.chat-side-row:hover { background: var(--surface-2); }
.chat-side-row.active, .chat-side-row.active:hover { background: var(--ink); color: var(--bg); font-weight: 550; }
.chat-side-row > .truncate { flex: 1; min-width: 0; }
.chat-side-row.unread > .truncate { font-weight: 650; }
.chat-side-row.add { color: var(--ink-4); }
.chat-unread { margin-left: auto; flex-shrink: 0; background: var(--accent); color: var(--accent-ink); font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 8px; line-height: 1.5; min-width: 17px; text-align: center; }
.chat-unread[hidden] { display: none; }
.chat-dm-search { position: relative; padding: 0 8px 8px; }
.chat-dm-search svg { position: absolute; left: 18px; top: 9px; color: var(--ink-4); }
.chat-dm-search input { width: 100%; padding: 6px 10px 6px 28px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font-size: 12.5px; font-family: inherit; outline: none; }
.chat-dm-empty { padding: 6px 10px 8px; font-size: 12px; color: var(--ink-4); }
.chat-dm-extra { display: none; }
.chat-side.searching .chat-dm-extra { display: flex; }

/* 접속 표시 점 — active(초록) · away(노랑) · offline(회색). 사용자 결정 2026-09-17: 3단계 */
.chat-avatar-wrap { position: relative; display: inline-flex; flex-shrink: 0; }
.presence-dot { position: absolute; right: -2px; bottom: -2px; width: 8px; height: 8px; border-radius: 50%; background: #A3A3A3; border: 2px solid var(--bg); }
.presence-dot[data-state="active"] { background: #10B981; }
.presence-dot[data-state="away"] { background: #F59E0B; }
.presence-dot[data-state="offline"] { background: #A3A3A3; }

/* ── 오른쪽 대화 ── */
.chat-main { display: flex; flex-direction: column; min-width: 0; background: var(--bg); overflow: hidden; position: relative; }
.chat-empty { flex: 1; display: grid; place-items: center; padding: 24px; text-align: center; }
.chat-empty-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--surface-2); display: grid; place-items: center; margin: 0 auto 14px; color: var(--ink-4); }
.chat-empty h2 { font-size: 16px; font-weight: 650; margin: 0 0 6px; }
.chat-empty p { font-size: 13px; color: var(--ink-4); margin: 0 0 16px; line-height: 1.6; }

.chat-head { display: flex; align-items: center; gap: 10px; padding: 18px 28px; border-bottom: 1px solid var(--line); }
.chat-head-title { display: flex; align-items: center; gap: 6px; }
.chat-head-title h2 { font-size: 16px; font-weight: 600; letter-spacing: -.015em; margin: 0; }
.chat-head-sub { font-size: 12px; color: var(--ink-4); margin-top: 4px; }
.chat-head-right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.chat-head-avatars { display: flex; }
.chat-head-avatars > span { border: 2px solid var(--bg); border-radius: 50%; display: inline-flex; }
.chat-head-avatars > span + span { margin-left: -8px; }
.chat-back { margin-right: 2px; flex-shrink: 0; display: none; }
.chat-pin-btn { position: relative; }
.chat-pin-btn.has svg { color: var(--warn); }
.chat-pin-count { position: absolute; top: -3px; right: -3px; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 9.5px; font-weight: 700; line-height: 15px; text-align: center; border: 1.5px solid var(--bg); }
.chat-pin-count[hidden] { display: none; }

/* 채널 메뉴 팝오버(원본 ChannelMenu) */
.chat-menu-wrap { position: relative; }
.chat-menu { position: absolute; top: 36px; right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); width: 220px; padding: 6px; z-index: 30; animation: chatIn .15s cubic-bezier(.2,.7,.2,1); }
.chat-menu[hidden] { display: none; }
.chat-menu-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; background: transparent; border: 0; font-size: 12.5px; font-weight: 500; color: var(--ink-2); font-family: inherit; cursor: default; transition: background .12s; text-decoration: none; text-align: left; }
.chat-menu-item svg { color: var(--ink-3); flex-shrink: 0; }
.chat-menu-item span { flex: 1; text-align: left; }
.chat-menu-item:hover { background: var(--surface-2); }
.chat-menu-item.danger { color: var(--danger); }
.chat-menu-item.danger svg { color: var(--danger); }
.chat-menu-item.danger:hover { background: color-mix(in oklch, var(--danger) 6%, transparent); }
.chat-menu-sep { height: 1px; background: var(--line); margin: 4px 6px; }

/* 고정 메시지 — 접힌 한 줄 / 펼친 패널 */
.chat-pin-bar { display: flex; align-items: center; gap: 10px; width: 100%; padding: 13px 28px; border: 0; border-bottom: 1px solid var(--line); background: color-mix(in oklch, var(--warn) 5%, var(--surface)); cursor: default; font-family: inherit; text-align: left; }
.chat-pin-bar svg:first-child { flex-shrink: 0; color: var(--warn); }
.chat-pin-bar b { font-size: 12.5px; color: var(--ink-2); flex-shrink: 0; }
.chat-pin-bar .chat-pin-bar-body { font-size: 12.5px; color: var(--ink-3); flex: 1; text-align: left; }
.chat-pin-bar .chat-pin-bar-more { font-size: 11.5px; color: var(--ink-4); flex-shrink: 0; }
.chat-pin-see { display: inline-flex; align-items: center; gap: 2px; flex-shrink: 0; font-size: 11.5px; font-weight: 600; color: var(--ink-4); }
.chat-pin-panel { padding: 14px 28px 16px; border-bottom: 1px solid var(--line); background: color-mix(in oklch, var(--warn) 5%, var(--surface)); max-height: 280px; overflow-y: auto; }
.chat-pin-panel-head { display: flex; align-items: center; gap: 7px; margin-bottom: 10px; }
.chat-pin-panel-head svg { color: var(--warn); flex-shrink: 0; }
.chat-pin-panel-head > span { font-size: 12.5px; font-weight: 650; color: var(--ink-2); }
.chat-pin-toggle { margin-left: auto; display: inline-flex; align-items: center; gap: 3px; border: 0; background: transparent; color: var(--ink-4); font-size: 11.5px; font-weight: 600; font-family: inherit; cursor: default; }
.chat-pin-list { display: flex; flex-direction: column; gap: 8px; }
.chat-pin-card { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: default; transition: border-color .15s; }
.chat-pin-card:hover { border-color: var(--line-strong); }
.chat-pin-card-main { flex: 1; min-width: 0; }
.chat-pin-card-head { display: flex; align-items: baseline; gap: 8px; }
.chat-pin-card-head b { font-size: 12.5px; font-weight: 600; }
.chat-pin-card-head span { font-size: 11px; color: var(--ink-4); }
.chat-pin-card-body { font-size: 13px; color: var(--ink-2); margin-top: 1px; }
.chat-pin-card .icon-btn { width: 26px; height: 26px; flex-shrink: 0; }

/* 메시지 목록 */
.chat-msgs { flex: 1; overflow-y: auto; padding: 0 0 20px; }
.chat-msgs-empty { text-align: center; color: var(--ink-4); font-size: 13px; padding: 48px 24px; }
.chat-day { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 2; padding: 10px 24px 12px; background: linear-gradient(var(--bg) 70%, transparent); pointer-events: none; }
.chat-day-line { flex: 1; height: 1px; background: var(--line); }
.chat-day-label { font-size: 11px; color: var(--ink-4); padding: 3px 10px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); }
.chat-loading-older { text-align: center; font-size: 11.5px; color: var(--ink-4); padding: 8px; }

.msg-row { padding: 12px 24px 2px; display: flex; gap: 12px; position: relative; transition: opacity .2s ease; }
.msg-row.grouped { padding: 2px 24px; }
.msg-row.pending { opacity: .5; }
.msg-row.pinned { background: color-mix(in oklch, var(--warn) 5%, transparent); }
.msg-row.msg-in { animation: chatIn .3s cubic-bezier(.2,.7,.2,1); }
.msg-row.msg-flash { animation: msgFlash 1.6s ease; border-radius: 8px; }
.msg-avatar { width: 36px; flex-shrink: 0; padding-top: 2px; }
.msg-row.grouped .msg-avatar { padding-top: 0; }
.msg-main { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.msg-author { font-size: 13.5px; font-weight: 600; letter-spacing: -.012em; }
.msg-time { font-size: 11px; color: var(--ink-4); }
.msg-pinned { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; color: var(--warn); font-weight: 600; }
.msg-edited { font-size: 10.5px; color: var(--ink-5); margin-left: 4px; }
.msg-reactions { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.msg-reaction { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; color: var(--ink-2); font-weight: 550; font-family: inherit; cursor: default; }
.msg-reaction > span:first-child { font-size: 13px; }
.msg-reaction.mine { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.msg-reaction-add { padding: 2px 6px; border-radius: 999px; background: transparent; border: 1px dashed var(--line-strong); color: var(--ink-4); font-size: 12px; display: inline-flex; align-items: center; cursor: default; }
.msg-replies { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--accent); font-size: 12px; font-weight: 600; font-family: inherit; cursor: default; }
.msg-replies svg:last-child { color: var(--ink-4); }
.msg-actions { position: absolute; top: 4px; right: 24px; display: flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-sm); opacity: 0; transform: translateY(-4px); transition: opacity .15s, transform .15s; }
.msg-row.grouped .msg-actions { top: -8px; }
.msg-row:hover .msg-actions, .msg-row.react-open .msg-actions { opacity: 1; transform: translateY(0); }
.msg-actions .icon-btn { width: 26px; height: 26px; }
.msg-react-pop { position: absolute; top: 38px; right: 24px; display: flex; gap: 2px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 5; animation: chatIn .2s; }
.msg-row.grouped .msg-react-pop { top: 22px; }
.msg-react-pop button, .chat-ctx-quick button { width: 30px; height: 30px; border-radius: 8px; font-size: 16px; border: 0; background: transparent; transition: background .12s, transform .12s; cursor: default; }
.msg-react-pop button:hover, .chat-ctx-quick button:hover { background: var(--surface-2); transform: scale(1.2); }

/* 첨부(원본 AttachmentList·AttachmentStrip) */
.chat-att { margin-top: 6px; max-width: 420px; }
.chat-att-head { display: flex; align-items: center; gap: 10px; }
.chat-att.open .chat-att-head { margin-bottom: 9px; }
.chat-att-toggle { display: flex; align-items: center; gap: 5px; background: transparent; border: 0; padding: 0; cursor: pointer; color: var(--ink-2); font-family: inherit; font-size: 12.5px; font-weight: 650; }
.chat-att-toggle svg { color: var(--ink-4); transition: transform .15s; }
.chat-att.open .chat-att-toggle svg { transform: rotate(90deg); }
.chat-att-sep { width: 1px; height: 11px; background: var(--line-strong); flex-shrink: 0; }
.chat-att-all { display: inline-flex; align-items: center; gap: 5px; background: transparent; border: 0; padding: 0; cursor: pointer; color: var(--ink-3); font-family: inherit; font-size: 12px; font-weight: 550; }
.chat-att-all.done { color: var(--accent); }
.chat-att-all.fail { color: var(--danger); }
.chat-att-list { display: none; flex-direction: column; gap: 8px; }
.chat-att.open .chat-att-list { display: flex; }
.chat-file-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 9px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; font-family: inherit; transition: background .15s, border-color .15s; }
.chat-file-row:not(:disabled):hover { background: var(--surface-2); border-color: var(--line-strong); }
.chat-file-row:not(:disabled):hover .chat-file-dl { color: var(--accent); background: var(--accent-soft); }
.chat-file-thumb { width: 46px; height: 46px; border-radius: 9px; flex-shrink: 0; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); display: grid; place-items: center; color: var(--ink-5); }
.chat-file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.chat-file-tile { width: 46px; height: 46px; border-radius: 9px; flex-shrink: 0; display: grid; place-items: center; font-size: 10px; font-weight: 700; letter-spacing: .02em; color: #fff; background: var(--fp-color, #6B7280); }
.chat-file-main { flex: 1; min-width: 0; }
.chat-file-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.chat-file-sub { font-size: 11.5px; color: var(--ink-4); margin-top: 2px; }
.chat-file-sub.fail { color: var(--danger); }
.chat-file-dl { flex-shrink: 0; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--ink-4); transition: color .15s, background .15s; }
.chat-file-dl.done { color: var(--accent); }
.chat-file-dl.fail { color: var(--danger); }
.chat-strip { display: flex; gap: 8px; flex-wrap: wrap; padding: 8px 8px 2px; }
.chat-strip[hidden] { display: none; }
.chat-strip-item { position: relative; width: 112px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow-sm); }
.chat-strip-remove { position: absolute; top: 4px; right: 4px; z-index: 2; width: 18px; height: 18px; border-radius: 5px; border: 0; background: color-mix(in oklch, var(--ink) 55%, transparent); color: #fff; display: grid; place-items: center; cursor: pointer; }
.chat-strip-thumb { height: 64px; background: var(--surface-2); border-bottom: 1px solid var(--line); display: grid; place-items: center; }
.chat-strip-thumb img { width: 100%; height: 64px; object-fit: cover; display: block; }
.chat-strip-thumb .chat-file-tile { width: 38px; height: 38px; }
.chat-strip-overlay { position: absolute; top: 0; left: 0; right: 0; height: 64px; background: color-mix(in oklch, var(--ink) 32%, transparent); display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; }
.chat-strip-meta { padding: 6px 8px 8px; }
.chat-strip-name { font-size: 11px; font-weight: 550; }
.chat-strip-size { font-size: 10px; color: var(--ink-4); margin-top: 1px; }
.chat-strip-size.err { color: var(--danger); }
.chat-strip-bar { height: 3px; border-radius: 2px; background: var(--line); margin-top: 4px; overflow: hidden; }
.chat-strip-bar > div { height: 100%; background: var(--accent); transition: width .15s; }

/* 컴포저 */
.chat-composer-wrap { padding: 0 28px 20px; }
.chat-composer { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; display: flex; flex-direction: column; box-shadow: var(--shadow-sm); position: relative; }
.chat-composer-tools { display: flex; gap: 2px; padding: 6px 8px 0; align-items: center; }
.chat-composer textarea { width: 100%; border: 0; background: transparent; outline: none; padding: 4px 14px 8px; font-size: 14px; line-height: 1.5; resize: none; min-height: 38px; max-height: 160px; color: var(--ink); font-family: inherit; }
.chat-composer-foot { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px 8px 14px; }
.chat-composer-foot .mono { font-size: 11px; color: var(--ink-5); }
.chat-mention-pop { position: absolute; left: 0; bottom: calc(100% + 8px); width: 300px; max-height: 280px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 20; animation: chatIn .14s cubic-bezier(.2,.7,.2,1); }
.chat-mention-pop[hidden] { display: none; }
.chat-mention-hd { font-size: 10.5px; font-weight: 700; color: var(--ink-4); text-transform: uppercase; letter-spacing: .08em; padding: 4px 8px 6px; }
.chat-mention-row { width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 9px; border: 0; background: transparent; cursor: default; font-family: inherit; text-align: left; transition: background .1s; }
.chat-mention-row.on { background: var(--surface-2); }
.chat-mention-row .chat-mention-name { font-size: 13.5px; font-weight: 600; }
.chat-mention-row .chat-mention-role { font-size: 11.5px; color: var(--ink-4); }
.chat-mention-row .chat-mention-at { font-size: 12px; color: var(--ink-4); flex-shrink: 0; }

/* 파일 끌어다 놓기 덮개 */
.chat-drop { position: absolute; inset: 12px; z-index: 30; border-radius: 16px; border: 2px dashed var(--accent); background: color-mix(in oklch, var(--accent) 8%, var(--surface)); display: grid; place-items: center; pointer-events: none; text-align: center; }
.chat-drop[hidden] { display: none; }
.chat-drop-icon { width: 48px; height: 48px; border-radius: 14px; background: var(--surface); display: grid; place-items: center; margin: 0 auto 12px; color: var(--accent); box-shadow: var(--shadow-sm); }
.chat-drop-title { font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.chat-drop-sub { font-size: 12.5px; color: var(--ink-4); margin-top: 3px; }

/* 우클릭 메뉴(원본 MessageMenu) */
.chat-ctx-bg { position: fixed; inset: 0; z-index: 150; }
.chat-ctx-bg[hidden] { display: none; }
.chat-ctx { position: fixed; width: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; animation: chatIn .14s cubic-bezier(.2,.7,.2,1); }
.chat-ctx-quick { display: flex; gap: 2px; padding: 2px 2px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.chat-ctx-quick button { flex: 1; height: 32px; font-size: 17px; width: auto; }

/* 창(원본 ChatModal·ThreadModal·SearchModal 등) — 열림은 .on */
.chat-modal .modal { animation: chatIn .25s cubic-bezier(.2,.7,.2,1); }
.chat-modal .modal-body { padding: 18px 24px; }
.chat-modal .modal-foot { padding: 14px 24px; }
.chat-modal .modal-foot .mono { font-size: 11px; color: var(--ink-4); }
.chat-info-row { display: grid; grid-template-columns: 90px 1fr; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.chat-info-label { font-size: 11px; color: var(--ink-4); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.chat-info-value { font-size: 13.5px; color: var(--ink); display: flex; align-items: center; gap: 6px; }
.chat-warn { margin-top: 14px; padding: 12px; background: color-mix(in oklch, var(--warn) 8%, var(--surface)); border: 1px solid color-mix(in oklch, var(--warn) 25%, var(--line)); border-radius: 10px; font-size: 12px; color: var(--ink-2); line-height: 1.55; }
.chat-warn.danger { background: color-mix(in oklch, var(--danger) 7%, var(--surface)); border-color: color-mix(in oklch, var(--danger) 25%, var(--line)); }
.chat-warn-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.chat-warn-head svg { color: var(--warn); }
.chat-warn.danger .chat-warn-head svg { color: var(--danger); }
.chat-warn.inline { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.chat-modal-p { font-size: 13.5px; color: var(--ink-2); line-height: 1.6; margin: 0; }
.chat-scope-note { margin-bottom: 14px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 8px; line-height: 1.5; }
.chat-search-wrap { position: relative; margin-bottom: 14px; }
.chat-search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-4); }
.chat-search-wrap .input { padding-left: 36px; width: 100%; }
.chat-member-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.chat-member-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); width: 100%; border-left: 0; border-right: 0; border-top: 0; background: transparent; text-align: left; font-family: inherit; cursor: default; }
.chat-member-row:last-child { border-bottom: 0; }
.chat-member-row .chat-member-main { flex: 1; min-width: 0; }
.chat-member-row .chat-member-name { font-size: 13px; font-weight: 550; display: flex; align-items: center; gap: 6px; }
.chat-member-row .chat-member-name small { font-size: 10px; color: var(--ink-4); font-weight: 400; }
.chat-member-row .chat-member-role { font-size: 11.5px; color: var(--ink-4); }
.chat-member-row.selected { background: var(--surface-2); }
.chat-member-row.selected.danger { background: color-mix(in oklch, var(--danger) 8%, transparent); }
.chat-member-row input { display: none; }
.chat-check { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line-strong); display: grid; place-items: center; flex-shrink: 0; color: var(--bg); }
.chat-member-row.selected .chat-check { background: var(--ink); border-color: var(--ink); }
.chat-member-row.selected.danger .chat-check { background: var(--danger); border-color: var(--danger); color: #fff; }
.chat-member-row .chat-check svg { display: none; }
.chat-member-row.selected .chat-check svg { display: block; }
.chat-member-empty { padding: 36px; text-align: center; color: var(--ink-4); font-size: 13px; }
.chat-seg { display: inline-flex; gap: 4px; padding: 3px; background: var(--surface-2); border-radius: 8px; margin-bottom: 12px; }
.chat-seg button { padding: 6px 14px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-4); font-size: 12.5px; font-weight: 600; font-family: inherit; cursor: default; display: inline-flex; align-items: center; gap: 6px; }
.chat-seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.chat-seg button .num { opacity: .65; }
.chat-summary { margin-top: 12px; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 8px; }
.chat-summary[hidden] { display: none; }
.chat-name-wrap { position: relative; }
.chat-name-wrap > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-4); font-weight: 600; display: inline-flex; }
.chat-name-wrap .input { padding-left: 36px; font-size: 14px; width: 100%; }
.chat-name-hint { font-size: 11.5px; margin-top: 6px; line-height: 1.5; color: var(--ink-4); }
.chat-name-hint.conflict { color: var(--danger); }
.chat-name-hint b { color: var(--ink); font-weight: 600; }
.chat-form-label { font-size: 11px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; margin: 18px 0 8px; }
.chat-form-label:first-child { margin-top: 0; }
.chat-owner { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.chat-owner p { font-size: 11.5px; color: var(--ink-4); margin: 0 0 8px; line-height: 1.5; }
.chat-owner-none { font-size: 12px; color: var(--ink-4); }

/* 공감 더보기 격자 */
.chat-emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.chat-emoji-grid button { aspect-ratio: 1; border-radius: 10px; font-size: 22px; border: 1px solid transparent; background: var(--surface-2); transition: transform .12s, border-color .12s; cursor: default; }
.chat-emoji-grid button:hover { transform: scale(1.12); border-color: var(--line-strong); }

/* 메시지 삭제 확인 */
.chat-quote { padding: 10px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; color: var(--ink-2); line-height: 1.55; white-space: pre-wrap; word-break: break-word; }

/* 검색 결과 */
.chat-search-body { overflow-y: auto; flex: 1; min-height: 0; padding: 0 24px 18px; }
.chat-search-hint { text-align: center; color: var(--ink-4); font-size: 13px; padding: 28px 0; }
.chat-search-count { font-size: 11.5px; color: var(--ink-4); font-weight: 600; margin: 4px 2px 10px; }
.chat-search-list { display: flex; flex-direction: column; gap: 8px; }
.chat-search-hit { display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: default; font-family: inherit; transition: border-color .15s; width: 100%; }
.chat-search-hit:hover { border-color: var(--line-strong); }
.chat-search-hit-main { flex: 1; min-width: 0; }
.chat-search-hit-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.chat-search-hit-head b { font-size: 12.5px; font-weight: 600; flex-shrink: 0; }
.chat-search-hit-head span { font-size: 11px; color: var(--ink-4); }
.chat-search-hit-head small { font-size: 10.5px; color: var(--ink-5); flex-shrink: 0; }
.chat-search-hit-body { font-size: 13px; color: var(--ink-2); line-height: 1.5; margin-top: 2px; }
.chat-search-hit-body mark { background: color-mix(in oklch, var(--accent) 28%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* 스레드 */
.chat-thread-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-thread-icon { width: 34px; height: 34px; border-radius: 10px; background: var(--ink); color: var(--bg); display: grid; place-items: center; flex-shrink: 0; }
.chat-thread-head h3 { font-size: 16px; font-weight: 650; letter-spacing: -.02em; margin: 3px 0 0; }
.chat-thread-root { padding: 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.chat-thread-root .msg-head { align-items: baseline; }
.chat-thread-divider { display: flex; align-items: center; gap: 10px; margin: 16px 2px 14px; }
.chat-thread-divider span { font-size: 12px; font-weight: 600; color: var(--ink-3); white-space: nowrap; }
.chat-thread-divider div { flex: 1; height: 1px; background: var(--line); }
.chat-thread-empty { text-align: center; color: var(--ink-4); font-size: 13px; padding: 20px 0 8px; }
.chat-thread-list { display: flex; flex-direction: column; gap: 14px; }
.chat-thread-reply { display: flex; gap: 10px; }
.chat-thread-reply .msg-main { margin-top: 0; }
.chat-thread-foot { padding: 14px 24px; border-top: 1px solid var(--line); background: var(--surface-2); flex-shrink: 0; }
.chat-thread-composer { display: flex; gap: 8px; align-items: flex-end; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; padding: 6px; box-shadow: var(--shadow-sm); }
.chat-thread-composer textarea { flex: 1; min-height: 34px; max-height: 120px; font-size: 13.5px; background: transparent; border: 0; box-shadow: none; padding: 6px 8px; resize: none; outline: none; font-family: inherit; color: var(--ink); }
.chat-thread-composer .btn { padding: 0 14px; height: 36px; }

/* 토스트 */
.chat-toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); display: inline-flex; align-items: flex-start; gap: 10px; max-width: min(92vw, 560px); z-index: 200; animation: chatIn .2s; }
.chat-toast[hidden] { display: none; }
.chat-toast svg { flex-shrink: 0; margin-top: 2px; }
.chat-toast span { word-break: break-word; line-height: 1.45; }

@keyframes chatIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes msgFlash { 0%, 100% { background: transparent; } 25% { background: color-mix(in oklch, var(--accent) 16%, transparent); } }

/* 셸 알림 토스트(shell.js realtime — 결재·가입·게시글) */
.ws-toasts { position: fixed; right: 20px; bottom: 20px; z-index: 210; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.ws-toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; width: 320px; max-width: calc(100vw - 40px); padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); text-decoration: none; color: inherit; animation: chatIn .2s; }
.ws-toast-icon { width: 30px; height: 30px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex-shrink: 0; }
.ws-toast-title { font-size: 12.5px; font-weight: 650; }
.ws-toast-body { font-size: 12px; color: var(--ink-3); margin-top: 2px; line-height: 1.45; word-break: break-word; }

/* 데스크톱: 자동으로 열린 첫 방(data-explicit=false)은 실제로 읽는 중 — 서버가 남긴 배지·굵기는 chat.js가 0으로 맞추기 전에도 보이지 않게(BUG-0016 24번) */
@media (min-width: 769px) {
  .chat-wrap[data-explicit="false"] .chat-side-row.active .chat-unread { display: none; }
  .chat-wrap[data-explicit="false"] .chat-side-row.active.unread > .truncate { font-weight: 550; }
}

/* 모바일: 목록과 대화를 한 칸씩 */
@media (max-width: 768px) {
  .chat-wrap { grid-template-columns: 1fr; }
  .chat-wrap[data-explicit="false"] .chat-main { display: none; }
  .chat-wrap[data-explicit="true"] .chat-side { display: none; }
  /* 목록만 보이는 상태에서는 미리 골라 둔 첫 방을 활성으로 칠하지 않는다(열지 않은 방이 검게 보이던 문제) */
  .chat-wrap[data-explicit="false"] .chat-side-row.active { background: transparent; color: var(--ink-2); font-weight: 400; }
  .chat-wrap[data-explicit="false"] .chat-side-row.active:hover { background: var(--surface-2); }
  .chat-wrap[data-explicit="false"] .chat-side-row.active.unread > .truncate { font-weight: 650; }
  .chat-back { display: inline-flex; }
  .chat-head { padding: 14px; }
  .chat-composer-wrap { padding: 0 12px 12px; }
  .chat-pin-bar, .chat-pin-panel { padding-left: 14px; padding-right: 14px; }
}
