/* 聊天 on libenest.com (platform-chat.mjs, chat.js): the inbox, 訊息請求 and one conversation. One white column with its own
   top bar on a phone (the site's header and footer step aside; in a conversation the tab bar does too, for the field), a
   centred column on a computer. Muted text is #5f6672 (4.5:1 on white); my messages are blue with white text (4.6:1). */
.ch, .ch-sheet { --ch-ink:var(--lb-text,#101113); --ch-muted:var(--lb-text-2,#5f6672); --ch-line:var(--lb-line,#eef0f3); --ch-blue:#006bff; --ch-mine:#1f6fe0; --ch-other:var(--lb-surface-2,#eff1f4); --ch-danger:var(--lb-red-text,#c0262d); }
.ch { position:relative; width:100%; max-width:640px; margin:0 auto; color:var(--ch-ink); font-size:15px; background:var(--lb-bg,#fff); }
.ch .sr-only, .ch-sheet .sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.ch [hidden], .ch-sheet [hidden] { display:none !important; }
.ch :is(a, button, textarea, input):focus-visible, .ch-sheet :is(a, button, textarea, input):focus-visible { outline:2px solid var(--lb-link,var(--ch-blue)); outline-offset:2px; }

.ch-head { position:sticky; top:0; z-index:3; display:grid; grid-template-columns:52px minmax(0,1fr) 52px; align-items:center; height:52px; padding:0 4px; border-bottom:1px solid var(--ch-line); background:var(--lb-bg,#fff); }
.ch-head h1 { overflow:hidden; margin:0; font-size:17px; font-weight:700; text-align:center; text-overflow:ellipsis; white-space:nowrap; }
.ch-icon, .ch-icon-space { display:grid; place-items:center; width:44px; height:44px; padding:0; border:0; border-radius:50%; background:none; color:var(--ch-ink); cursor:pointer; }
.ch-head > :last-child { justify-self:end; }
.ch-status { margin:0; padding:40px 16px; color:var(--ch-muted); text-align:center; }

.ch-primary, .ch-secondary { display:inline-flex; align-items:center; justify-content:center; gap:6px; min-height:44px; padding:0 18px; box-sizing:border-box; border:0; border-radius:12px; font:inherit; font-size:15px; font-weight:700; text-decoration:none; cursor:pointer; }
.ch-primary { background:var(--ch-blue); color:#fff; }
.ch-primary-danger { background:var(--ch-danger); }
.ch-secondary { background:var(--lb-surface,#eff2f5); color:var(--ch-ink); }

.ch-gate, .ch-empty, .ch-gone { display:grid; justify-items:center; gap:10px; padding:48px 24px 24px; text-align:center; }
.ch-gate h2, .ch-empty h2, .ch-gone h2 { margin:6px 0 0; font-size:20px; font-weight:700; }
.ch-gate .ch-primary { margin-top:8px; min-width:200px; }
.ch-gate-mark { display:grid; place-items:center; width:84px; height:84px; border:2px solid var(--ch-ink); border-radius:50%; }

/* Faces: a person's photo or first letter, or a bubble's emoji on its colour. */
.ch-face { flex:none; display:grid; place-items:center; width:52px; height:52px; overflow:hidden; border-radius:50%; background:var(--lb-surface,#e9edf2); color:var(--ch-muted); font-size:19px; font-weight:700; }
.ch-face img { display:block; width:100%; height:100%; object-fit:cover; }
.ch-face-bubble { background:var(--ch, #1f9d55); color:#fff; font-size:26px; }

/* The inbox: one row per conversation, bold with a dot while something is new. */
.ch-requests { display:flex; align-items:center; gap:8px; min-height:48px; padding:0 16px; color:var(--lb-link,var(--ch-blue)); font-weight:700; text-decoration:none; }
.ch-requests b { margin-left:auto; min-width:22px; padding:1px 7px; border-radius:999px; background:var(--ch-blue); color:#fff; font-size:13px; text-align:center; }
.ch-list { display:grid; margin:0; padding:4px 0 24px; list-style:none; }
.ch-item { display:flex; align-items:center; gap:12px; min-height:72px; padding:8px 16px; color:inherit; text-decoration:none; }
.ch-item:hover { background:var(--lb-surface,#f7f8fa); }
.ch-item-text { display:grid; flex:1; gap:3px; min-width:0; }
.ch-item-text strong { overflow:hidden; font-size:15px; font-weight:600; text-overflow:ellipsis; white-space:nowrap; }
.ch-item-text small { display:flex; min-width:0; color:var(--ch-muted); font-size:14px; }
.ch-preview { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ch-when { flex:none; margin-left:4px; white-space:nowrap; }
.ch-item.is-unread strong, .ch-item.is-unread .ch-preview { color:var(--ch-ink); font-weight:700; }
.ch-dot { flex:none; width:10px; height:10px; border-radius:50%; background:var(--ch-blue); }

/* One conversation: the head, the messages, the field at the bottom. */
.ch-thread-head { grid-template-columns:52px minmax(0,1fr) 52px; }
.ch-who { display:flex; align-items:center; gap:10px; min-width:0; color:inherit; text-decoration:none; }
.ch-who .ch-face { width:34px; height:34px; font-size:14px; }
.ch-who .ch-face-bubble { font-size:18px; }
.ch-who-text { display:grid; min-width:0; line-height:1.25; }
.ch-who-text strong, .ch-who-text small { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ch-who-text strong { font-size:16px; }
.ch-who-text small { color:var(--ch-muted); font-size:12px; }
.ch-scroll { overflow-y:auto; overscroll-behavior:contain; padding:8px 12px 12px; }
/* 集合點 (旅伴模式), pinned above a bubble's chat: where and when, a tap opens the bubble's map. */
.ch-meetup { display:flex; align-items:center; gap:10px; margin:8px 12px 0; padding:8px 12px; border:1px solid #f3d2d2; border-radius:14px; background:var(--lb-surface,#fff7f7); color:var(--ch-ink); text-decoration:none; }
.ch-meetup[hidden] { display:none; }
.ch-meetup-pin { font-size:20px; }
.ch-meetup-text { display:grid; flex:1; min-width:0; }
.ch-meetup-text small { color:var(--ch-muted); font-size:12px; font-weight:700; }
.ch-meetup-text strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ch-meetup b { flex:none; font-size:16px; }
.ch-older { display:block; margin:4px auto 10px; padding:8px 14px; border:0; border-radius:999px; background:var(--lb-surface,#eff2f5); color:var(--ch-ink); font:inherit; font-size:13px; font-weight:600; cursor:pointer; }
.ch-messages { display:grid; gap:2px; margin:0; padding:0; list-style:none; }
.ch-msg { display:grid; gap:2px; margin-top:8px; }
.ch-msg.is-follow { margin-top:0; }
.ch-time { margin:10px 0 4px; color:var(--ch-muted); font-size:12px; text-align:center; }
.ch-row { display:flex; align-items:flex-end; gap:6px; min-width:0; }
.ch-msg.is-mine .ch-row { flex-direction:row-reverse; }
.ch-row > .ch-face { width:28px; height:28px; font-size:12px; }
.ch-face-space { visibility:hidden; }
.ch-box { display:grid; justify-items:start; gap:2px; min-width:0; max-width:76%; }
.ch-msg.is-mine .ch-box { justify-items:end; }
.ch-from { padding:0 12px; color:var(--ch-muted); font-size:12px; }
.ch-bubble { margin:0; padding:9px 13px; border-radius:20px; background:var(--ch-other); line-height:1.45; white-space:pre-wrap; overflow-wrap:anywhere; -webkit-user-select:text; user-select:text; }
.ch-msg.is-mine .ch-bubble { background:var(--ch-mine); color:#fff; }
.ch-bubble.ch-gone-text, .ch-msg.is-mine .ch-bubble.ch-gone-text { border:1px solid var(--lb-line,#dfe3e8); background:var(--lb-bg,#fff); color:var(--ch-muted); font-style:italic; }
.ch-emoji { margin:0; font-size:40px; line-height:1.15; }
.ch-photo { display:block; overflow:hidden; max-width:min(260px, 100%); border-radius:18px; background:var(--lb-surface,#e9edf2); }
.ch-photo img { display:block; max-width:100%; max-height:340px; object-fit:cover; }
.ch-place-card { display:flex; align-items:center; gap:10px; min-width:200px; max-width:100%; padding:10px 14px; border:1px solid var(--lb-line,#dfe3e8); border-radius:18px; background:var(--lb-bg,#fff); color:var(--ch-ink); text-decoration:none; }
.ch-place-pin { display:grid; place-items:center; width:40px; height:40px; border-radius:12px; background:var(--lb-surface,#eef4ff); font-size:20px; }
.ch-place-card span:last-child { display:grid; min-width:0; }
.ch-place-card strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ch-place-card small { color:var(--ch-muted); font-size:12px; }
.ch-story-reply { display:grid; justify-items:inherit; gap:4px; }
.ch-story-label { color:var(--ch-muted); font-size:12px; }
.ch-story { display:block; overflow:hidden; width:96px; height:160px; border-radius:14px; background:var(--lb-surface,#e9edf2); }
.ch-story img { display:block; width:100%; height:100%; object-fit:cover; }
.ch-story-gone { display:grid; place-items:center; height:auto; min-height:44px; padding:8px 12px; box-sizing:border-box; color:var(--ch-muted); font-size:12px; text-align:center; }
.ch-msg-more { flex:none; width:32px; height:32px; padding:0; border:0; border-radius:50%; background:none; color:var(--ch-muted); font-size:18px; line-height:1; cursor:pointer; opacity:0; }
.ch-row:hover .ch-msg-more, .ch-msg-more:focus-visible { opacity:1; }
.ch-read { margin:4px 4px 0 0; color:var(--ch-muted); font-size:12px; text-align:right; }

/* The bars that replace the field: a request (接受／刪除／封鎖), a block, a closed account. */
.ch-bar { display:grid; gap:10px; padding:14px 16px calc(14px + env(safe-area-inset-bottom)); border-top:1px solid var(--ch-line); background:var(--lb-elevated,#fff); text-align:center; }
.ch-bar p { margin:0; color:var(--ch-muted); line-height:1.5; }
.ch-bar-actions { display:grid; grid-template-columns:repeat(3, minmax(0,1fr)); gap:8px; }
.ch-bar-actions .ch-primary, .ch-bar-actions .ch-secondary { padding:0 8px; }

.ch-compose { padding:8px 10px calc(8px + env(safe-area-inset-bottom)); border-top:1px solid var(--ch-line); background:var(--lb-bg,#fff); }
.ch-quick-row { display:flex; justify-content:space-between; gap:4px; padding:0 4px 8px; }
.ch-quick { display:grid; place-items:center; width:44px; height:44px; padding:0; border:0; border-radius:50%; background:var(--lb-surface,#f3f5f8); font-size:24px; cursor:pointer; }
.ch-field { display:flex; align-items:flex-end; gap:6px; padding:4px; border:1px solid var(--lb-line,#dfe3e8); border-radius:24px; background:var(--lb-bg,#fff); }
.ch-round, .ch-send { flex:none; display:grid; place-items:center; width:40px; height:40px; padding:0; border:0; border-radius:50%; background:none; color:var(--ch-ink); font-size:22px; cursor:pointer; }
.ch-round:first-child { background:var(--ch-blue); color:#fff; }
.ch-send { color:var(--lb-link,var(--ch-blue)); }
.ch-field textarea { flex:1; min-width:0; min-height:40px; max-height:132px; margin:0; padding:9px 4px; box-sizing:border-box; border:0; background:none; color:var(--ch-ink); font:inherit; font-size:16px; line-height:1.4; resize:none; }
.ch-field textarea:focus { outline:none; }
.ch-field:focus-within { border-color:var(--lb-link,var(--ch-blue)); }

/* Sheets: from the bottom on a phone, in the middle on a computer. */
.ch-sheet { width:100%; max-width:480px; max-height:92dvh; margin:auto auto 0; padding:0; border:0; border-radius:20px 20px 0 0; background:var(--lb-elevated,#fff); color:var(--ch-ink); }
.ch-sheet::backdrop { background:rgb(16 17 19 / 40%); }
.ch-sheet-body { display:grid; gap:4px; padding:12px 16px calc(16px + env(safe-area-inset-bottom)); }
.ch-sheet-body h2 { margin:6px 0 2px; font-size:18px; }
.ch-sheet-lead { margin:0 0 6px; color:var(--ch-muted); font-size:14px; line-height:1.5; }
.ch-menu-item { display:flex; align-items:center; gap:12px; min-height:52px; padding:0 8px; border:0; border-radius:12px; background:none; color:var(--ch-ink); font:inherit; font-size:16px; font-weight:600; text-align:left; text-decoration:none; cursor:pointer; }
.ch-menu-item:hover { background:var(--lb-surface,#f5f7fa); }
.ch-menu-item.ch-danger { color:var(--ch-danger); }
.ch-menu-quiet { justify-content:center; color:var(--ch-muted); }
.ch-reasons { display:grid; gap:2px; margin:0; padding:0; border:0; }
.ch-reason { display:flex; align-items:center; gap:10px; min-height:44px; padding:0 4px; }
.ch-reason input { width:20px; height:20px; accent-color:var(--ch-danger); }
.ch-note { display:grid; gap:6px; margin-top:6px; color:var(--ch-muted); font-size:14px; }
.ch-note textarea { padding:10px; border:1px solid var(--lb-line,#dfe3e8); border-radius:12px; font:inherit; font-size:16px; resize:vertical; }
.ch-error { margin:4px 0 0; color:var(--ch-danger); font-size:14px; }
.ch-actions { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-top:10px; }
@media (min-width:821px) { .ch-sheet { margin:auto; border-radius:20px; } }

/* 地點: the map's place picker (the one 分享 uses), over the conversation; only places on the map, no new spots here. */
.ch-place .ag-share-picker { position:fixed; inset:0; z-index:80; display:flex; flex-direction:column; overflow:auto; background:var(--lb-elevated,#fff); }
.ch-place .ag-share-picker[hidden] { display:none; }
.ch-place .ag-share-new { display:none !important; }

/* On a phone: the page is the conversation. */
@media (max-width:820px) {
  .chat-body .ag-header, .chat-body .ag-footer, .chat-body .ag-header-space { display:none !important; }
  .chat-body main { padding:0; }
  .chat-thread-body .bottom-nav { display:none !important; }
  .chat-thread-body .page-shell { padding-bottom:0 !important; }
  .ch-thread { display:flex; flex-direction:column; height:100dvh; }
  .ch-thread .ch-scroll { flex:1; }
  .ch-thread .ch-head { flex:none; }
}
@media (min-width:821px) {
  .chat-body main { padding:32px 16px 56px; background:var(--lb-surface,#f5f7fa); }
  .ch { border:1px solid var(--ch-line); border-radius:20px; overflow:hidden; }
  .ch-thread { display:flex; flex-direction:column; height:min(78vh, 760px); }
  .ch-thread .ch-scroll { flex:1; }
}
