/* Community list and chat. Builds on app.css tokens (docs/UI-PREMIUM-DESIGN.md). */

/* Group list: rows on the page, separated by hairlines, no box around them */
.groups { display: grid; max-width: 760px; }
.group { display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center; padding: 14px 4px; color: inherit; text-decoration: none; border-bottom: 1px solid var(--line); }
.group:first-child, .join-row:first-child { border-top: 1px solid var(--line); }
.group:hover { background: rgba(255,255,255,.7); }
.avatar { position: relative; width: 52px; height: 52px; border-radius: 16px; background: #ebe4ee; color: var(--ink-2); display: grid; place-items: center; font-weight: 750; font-size: 1.25rem; overflow: hidden; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.group-text { display: grid; gap: 1px; min-width: 0; }
.group-name { font-weight: 700; font-size: 1.0625rem; line-height: 1.3; letter-spacing: -0.01em; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.group-last { color: var(--muted); font-size: .9375rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-side { display: grid; justify-items: end; gap: 6px; }
.group-time { color: var(--muted); font-size: .8125rem; }
.has-unread .group-time { color: var(--brand-deep); font-weight: 650; }
.has-unread .group-last { color: var(--ink-2); }
.badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--brand); color: #fff; font-size: .75rem; font-weight: 700; display: grid; place-items: center; }
.groups > .empty { border: 0; padding: 0; color: var(--muted); }

/* Chat layout: header, scrolling messages, composer; fills the viewport. */
.chat-body { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.chat-bar .bar-in { max-width: 880px; gap: 6px; }
.back { display: grid; place-items: center; width: 44px; height: 44px; margin-left: -10px; color: var(--ink); border-radius: 50%; }
.back:hover { background: var(--page); }
.back svg, .icon svg { width: 22px; height: 22px; }
.chat-title { flex: 1; min-width: 0; display: grid; text-align: left; background: none; border: 0; padding: 4px 8px; border-radius: 12px; cursor: pointer; color: var(--ink); font: inherit; }
.chat-title:hover { background: var(--page); }
.chat-title .t-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.0625rem; }
.chat-title .t-small { font-size: .8125rem; }
/* The header opens the details panel: a chevron says so */
.chat-bar .chev { width: 9px; height: 9px; border-right: 2px solid var(--muted); border-top: 2px solid var(--muted); transform: rotate(45deg); margin: 0 10px 0 2px; flex: none; pointer-events: none; }
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; max-width: 880px; margin: 0 auto; background: var(--page); }
@media (min-width: 900px) { .chat { box-shadow: 0 0 0 1px var(--line); } }
.scroller { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 10px 14px 14px; position: relative; }
.sentinel { height: 1px; }
.row { display: flex; flex-direction: column; content-visibility: auto; contain-intrinsic-size: auto 70px; }
.row.flash .bubble { box-shadow: 0 0 0 3px var(--focus); }
.day { align-self: center; margin: 16px 0 8px; padding: 4px 12px; border-radius: 999px; background: #fff; color: var(--muted); font-size: .75rem; font-weight: 650; box-shadow: 0 0 0 1px var(--line); }
.unread-mark { display: flex; align-items: center; gap: 10px; margin: 12px 0; color: var(--brand-deep); font-size: .8125rem; font-weight: 700; }
.unread-mark::before, .unread-mark::after { content: ""; flex: 1; height: 1px; background: rgba(227,0,71,.35); }
.system { align-self: center; margin: 8px 0; color: var(--muted); font-size: .8125rem; text-align: center; max-width: 80%; }

.bubble { max-width: min(82%, 560px); margin: 2px 0; padding: 8px 12px 6px; border-radius: 18px 18px 18px 6px; background: #fff; box-shadow: 0 1px 1px rgba(34,23,39,.06); cursor: pointer; }
.bubble.me { align-self: flex-end; border-radius: 18px 18px 6px 18px; background: #fbe4ec; box-shadow: none; }
.bubble:focus-visible { outline-offset: 1px; }
.bubble .who { display: block; font-size: .8125rem; font-weight: 700; color: var(--hue, var(--ink-2)); margin-bottom: 1px; }
.bubble .h0 { --hue: #a4134f; } .bubble .h1 { --hue: #1d6b52; } .bubble .h2 { --hue: #8a4b0f; }
.bubble .h3 { --hue: #3d4fa8; } .bubble .h4 { --hue: #7a2f96; } .bubble .h5 { --hue: #0f6577; }
.bubble .flags { font-size: .75rem; color: var(--muted); }
.bubble p { margin: 2px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .deleted { font-style: italic; color: var(--muted); }
.bubble .meta { font-size: .75rem; color: var(--muted); text-align: right; margin-top: 2px; }
.bubble .mention { color: var(--brand-deep); font-weight: 650; }
.bubble .muted { color: var(--muted); }
.bubble .photo { display: block; width: 100%; max-width: 320px; max-height: 360px; object-fit: cover; border-radius: 12px; background: #e9e3ec; margin: 2px 0 4px; }
.bubble .clip { display: block; width: 100%; max-width: 360px; border-radius: 12px; background: #000; margin: 2px 0 4px; }
.bubble audio { width: 260px; max-width: 100%; }
.bubble .file { display: grid; gap: 2px; padding: 10px 12px; border-radius: 12px; background: rgba(34,23,39,.05); color: var(--ink); text-decoration: none; min-width: 200px; margin: 2px 0 4px; }
.bubble .file-name { font-weight: 650; overflow-wrap: anywhere; }
.bubble .file-size { font-size: .8125rem; color: var(--muted); }
.bubble .quote { display: grid; text-align: left; width: 100%; border: 0; border-left: 3px solid var(--hue, var(--brand)); background: rgba(34,23,39,.05); border-radius: 8px; padding: 5px 9px; margin: 2px 0 4px; font: inherit; cursor: pointer; color: inherit; }
.bubble .quote .qt { font-size: .875rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Announcements (templates) read as notices across the chat, not as one person's bubble */
.bubble.notice { align-self: center; width: min(100%, 520px); max-width: none; margin: 10px 0; padding: 14px 16px 8px; border-radius: 18px; background: #fff; box-shadow: 0 0 0 1px var(--line); }
.bubble .tpl-head { display: block; font-size: 1.0625rem; letter-spacing: -0.01em; margin-bottom: 2px; }
.bubble .tpl-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 2px; }
.bubble.private { background: transparent; box-shadow: none; border: 1.5px dashed #b9a9c0; }
.jump { position: sticky; bottom: 8px; margin-left: auto; display: block; border: 0; border-radius: 999px; padding: 10px 16px; background: var(--ink); color: #fff; font: inherit; font-size: .875rem; font-weight: 600; cursor: pointer; box-shadow: 0 6px 20px rgba(34,23,39,.25); }

.reply-bar { display: flex; gap: 8px; align-items: center; padding: 8px 12px; background: #fff; border-top: 1px solid var(--line); }
.reply-bar > div { flex: 1; min-width: 0; display: grid; border-left: 3px solid var(--brand); padding-left: 10px; }
.reply-bar span { color: var(--muted); font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readonly { margin: 0; padding: 16px; text-align: center; color: var(--muted); background: #fff; border-top: 1px solid var(--line); }
.composer { display: flex; gap: 6px; align-items: flex-end; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); }
.composer textarea { flex: 1; font: inherit; resize: none; max-height: 140px; min-height: 44px; padding: 10px 16px; border: 1px solid transparent; border-radius: 22px; background: var(--page); color: var(--ink); }
.composer textarea:focus { outline: none; border-color: var(--ink); background: #fff; }
.icon { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--ink-2); font-size: 1.4rem; line-height: 1; cursor: pointer; }
.icon:hover { background: var(--page); color: var(--ink); }
.send { min-height: 44px; padding: 0 18px; }

.sheet { border: 0; border-radius: 20px; padding: 8px; min-width: 240px; color: var(--ink); box-shadow: 0 24px 60px rgba(34,23,39,.28); }
.sheet::backdrop { background: rgba(28,19,32,.42); }
.sheet button[data-do] { display: block; width: 100%; text-align: left; font: inherit; border: 0; background: none; padding: 12px 14px; border-radius: 12px; cursor: pointer; color: var(--ink); }
.sheet button[data-do]:hover { background: var(--page); }
.sheet .danger { color: #b0001f; }
.sheet.about { padding: 20px; max-width: 420px; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: .875rem; box-shadow: 0 10px 30px rgba(34,23,39,.3); }
.pending-row .bubble { opacity: .85; }
.pending-actions { display: flex; gap: 6px; margin-top: 6px; }
.banner { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 8px 12px; background: #fff4d6; color: #5c4400; font-size: .9rem; }

/* Batch 2: details panel, members, lists, forward, mentions */
.sheet.panel { width: min(520px, calc(100vw - 24px)); max-height: min(86dvh, 760px); padding: 16px 18px 18px; overflow-y: auto; }
.panel-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.panel-head .d-title { flex: 1; min-width: 0; }
.panel-head h2 { margin: 0; overflow-wrap: anywhere; }
.panel-head .t-small { margin: 2px 0 0; }
.panel-head .t-small:empty { display: none; }
.icon.small { width: 44px; height: 44px; font-size: 1.15rem; }
.d-about { padding: 12px 14px; background: var(--page); border-radius: 12px; margin: 0 0 14px; }
.d-desc { color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; font-size: .9375rem; }
.d-desc.clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.d-desc a { color: var(--brand-deep); }
.link-btn { font: inherit; font-weight: 650; font-size: .9375rem; color: var(--ink); background: none; border: 0; padding: 0; min-height: 44px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.d-edit { display: grid; gap: 10px; margin: 8px 0 12px; }
.d-edit label { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; }
.d-edit input, .d-edit textarea { font: inherit; padding: 9px 12px; border: 1.5px solid #d9d1dc; border-radius: 10px; }
.d-edit-actions { display: flex; gap: 8px; }
.d-settings { display: grid; margin: 0 0 14px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.switch { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 14px; min-height: 52px; cursor: pointer; margin: 0; font-weight: 600; font-size: 1rem; }
.switch + .switch { border-top: 1px solid var(--line); }
.switch small { display: block; font-weight: 400; color: var(--muted); font-size: .8125rem; }
/* A switch, drawn from the checkbox itself */
.switch input { -webkit-appearance: none; appearance: none; flex: none; width: 46px; height: 28px; min-height: 0; padding: 0; border: 0; border-radius: 99px; background: #cfc5d3; position: relative; cursor: pointer; transition: background-color .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(18px); }
.switch input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.d-links { display: grid; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin: 6px 0 14px; }
.d-links button { text-align: left; font: inherit; font-weight: 600; background: none; border: 0; padding: 0 14px; min-height: 52px; cursor: pointer; color: var(--ink); display: flex; align-items: center; justify-content: space-between; }
.d-links button::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-top: 2px solid var(--muted); transform: rotate(45deg); margin-right: 4px; }
.d-links button + button { border-top: 1px solid var(--line); }
.d-links button:hover { background: var(--page); }
.d-h { font-size: 1rem; margin: 4px 0 6px; }
.members { list-style: none; margin: 0 0 8px; padding: 0; }
.member { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.member + .member { border-top: 1px solid var(--line); }
.avatar.small { width: 36px; height: 36px; font-size: .95rem; flex: none; }
.member-text { flex: 1; min-width: 0; display: grid; }
.member-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-phone { color: var(--muted); font-size: .85rem; }
.pill { font-size: .75rem; font-weight: 650; color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); padding: 2px 8px; border-radius: 999px; }
.danger-btn { color: #b0001f; margin-top: 8px; width: 100%; }
.mm-name { margin: 6px 14px 4px; font-weight: 700; }
#member-menu button[data-m] { display: block; width: 100%; text-align: left; font: inherit; border: 0; background: none; padding: 12px 14px; border-radius: 10px; cursor: pointer; }
#member-menu button[data-m]:hover { background: var(--page); }
.msg-list { list-style: none; margin: 0; padding: 0; }
.msg-list li { display: flex; align-items: center; gap: 6px; }
.msg-list li + li { border-top: 1px solid var(--line); }
.msg-item { flex: 1; min-width: 0; display: grid; gap: 1px; text-align: left; font: inherit; color: inherit; background: none; border: 0; padding: 10px 4px; cursor: pointer; }
.msg-item:hover { background: var(--page); }
.msg-item .who { font-size: .8rem; font-weight: 700; color: var(--brand-deep); }
.msg-item .qt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rules { padding-left: 20px; display: grid; gap: 8px; }
.fw-list { display: grid; margin: 8px 0 14px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.fw-row { display: flex; gap: 10px; align-items: center; padding: 11px 14px; cursor: pointer; }
.fw-row + .fw-row { border-top: 1px solid var(--line); }
.fw-row input { width: 18px; height: 18px; accent-color: var(--brand); }
.fw-row span { flex: 1; }
.fw-row.off { color: var(--muted); cursor: default; }
.mentions { display: grid; background: #fff; border-top: 1px solid var(--line); max-height: 220px; overflow-y: auto; }
.mention-opt { text-align: left; font: inherit; border: 0; background: none; padding: 10px 16px; cursor: pointer; }
.mention-opt:hover, .mention-opt:focus { background: var(--page); }
.readonly .btn { margin-left: 6px; }
.joinable { max-width: 760px; margin-top: 28px; }
.joinable h2 { font-size: 1.25rem; font-weight: 750; letter-spacing: -0.015em; margin: 0 0 4px; }
.join-intro { margin: 0 0 12px; }
#groups:empty + .joinable { margin-top: 0; }
.join-row { display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center; padding: 14px 4px; border-bottom: 1px solid var(--line); }

/* Batch 3: voice notes, the Send sheet */
.recording { display: flex; gap: 10px; align-items: center; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); font-weight: 600; }
.recording .spacer { flex: 1; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #d4002a; animation: rec 1s infinite alternate; }
@keyframes rec { to { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } }
.ss-list { display: grid; gap: 8px; margin: 8px 0 12px; max-height: 50dvh; overflow-y: auto; }
.ss-row { display: flex; gap: 10px; align-items: center; }
.ss-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; background: #e5dde8; flex: none; }
.ss-icon { width: 56px; height: 56px; display: grid; place-items: center; font-size: 1.6rem; background: var(--page); border-radius: 8px; flex: none; }
.ss-text { display: grid; min-width: 0; }
.ss-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-refused { color: #b0001f; font-size: .9rem; margin: 2px 0; }
.warn { color: #7a5600; }
#ss-caption { width: 100%; font: inherit; padding: 10px 12px; border: 1.5px solid #d9d1dc; border-radius: 12px; margin-bottom: 12px; resize: vertical; }

/* Notifications on this device (docs/PUSH-PLAN.md §5) */
.push-card { display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; align-items: center; margin: 0 0 18px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.push-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); }
.push-card .push-text, .push-row .push-text { margin: 0; }
.push-card .push-note, .push-row .push-note { grid-column: 1 / -1; margin: 0; color: var(--muted); }
.push-card .push-note:empty, .push-row .push-note:empty { display: none; }
.push-card button[hidden], .push-row button[hidden] { display: none; }
