/* Community: the feed with topics down the side (and how it works beside it on wide screens), a thread, and the
   compose dialog. Phones get the topics as a row of chips over the feed. */

.community-layout { width: 100%; max-width: 1240px; margin-inline: auto; }
.community-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 28px; padding: 16px 16px 40px; align-items: start; }

/* Topics: a row of chips on phones… */
.topics { position: sticky; top: 0; z-index: 2; margin: 0 -16px 12px; padding: 4px 0 10px; background: var(--bg); }
.topics-list { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-inline: 16px; }
.topics-list::-webkit-scrollbar { display: none; }
.topic-item {
  display: inline-flex; align-items: center; gap: 8px; flex: none; min-height: 36px; padding: 0 14px; border-radius: 999px; font-size: 13.5px;
  border: 1px solid var(--divider); color: var(--text); white-space: nowrap; transition: background-color .12s, color .12s;
}
.topic-item .ph { display: none; }
.topic-item.on { border-color: var(--accent); background: rgb(var(--glow-rgb) / .14); color: var(--a200); }
@media (hover: hover) { .topic-item:not(.on):hover { background: rgb(var(--glow-rgb) / .07); } }

/* …a sidebar from tablet width, like the admin console's. */
@media (min-width: 900px) {
  .community-layout { grid-template-columns: 210px minmax(0, 1fr); padding-inline: 28px; }
  .topics { top: 8px; margin: 0; padding: 0; background: none; }
  .topics-list { flex-direction: column; gap: 2px; overflow: visible; padding: 0; }
  .topic-item { width: 100%; min-height: 40px; padding: 0 12px; border: 0; border-radius: 10px; font-size: 14.5px; color: var(--n300); }
  .topic-item .ph { display: inline-flex; color: var(--n500); }
  .topic-item.on { background: var(--a900); color: var(--accent); font-weight: 500; }
  .topic-item.on .ph { color: var(--accent); }
  .topic-item:not(.on):hover { color: var(--text); }
}
.community-side { display: none; }
.community-info { display: inline-grid; }
@media (min-width: 1240px) {
  .community-layout { grid-template-columns: 210px minmax(0, 1fr) 280px; }
  .community-side { display: block; position: sticky; top: 8px; }
  .community-info { display: none; }
}
.community-ask-btn { margin-inline-start: 6px; }
@media (max-width: 599px) { .community-ask-btn { display: none; } }

.feed { display: flex; flex-direction: column; gap: 10px; min-width: 0; max-width: 720px; width: 100%; }
.ask-prompt {
  display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 10px 18px; border-radius: 999px; text-align: start;
  background: var(--surface); box-shadow: 0 0 0 1px var(--divider); color: var(--n500); font-size: 15px; transition: box-shadow .15s;
}
.ask-prompt .ph { color: var(--n400); }
@media (hover: hover) { .ask-prompt:hover { box-shadow: 0 0 0 1px var(--a600), 0 6px 18px -10px var(--shadow); color: var(--n400); } }

/* A post: the whole card is a link to its thread (a stretched link), with its own buttons above it. */
.post-card, .khala-question { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 14px 8px 2px 16px; border-radius: var(--r-card); }
:root[dir="rtl"] .post-card, :root[dir="rtl"] .khala-question { padding: 14px 16px 2px 8px; }
.post-card { background: var(--surface); box-shadow: 0 0 0 1px color-mix(in srgb, var(--divider) 60%, transparent); transition: box-shadow .15s; }
@media (hover: hover) { .post-card:not(.folded):hover { box-shadow: 0 0 0 1px var(--a700), 0 8px 22px -14px var(--shadow); } }
.post-card-link { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.post-card-link:focus-visible { outline-offset: 2px; }
.post-card > :not(.post-card-link), .khala-question > :not(.post-card-link) { position: relative; }
.post-card .post-footer, .khala-question .above-link, .post-card .folded-note { z-index: 2; }
.post-card > .author-row, .post-card > .under-review, .post-card > .post-text, .post-card > .folded-note { margin-inline-end: 8px; pointer-events: none; }
.post-card > .folded-note { pointer-events: auto; }
.post-text { font-size: 15px; line-height: 1.55; white-space: pre-line; overflow-wrap: anywhere; }
.post-text.clamp { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }

.khala-question {
  padding-bottom: 12px; background: linear-gradient(135deg, color-mix(in srgb, var(--section) 55%, var(--surface)), var(--surface));
  box-shadow: 0 0 0 1px var(--a800), 0 0 26px -14px var(--glow);
}
:root[dir="rtl"] .khala-question { background: linear-gradient(225deg, color-mix(in srgb, var(--section) 55%, var(--surface)), var(--surface)); padding-bottom: 12px; }
.khala-question-text { font-size: 17.5px; font-weight: 500; line-height: 1.4; }

.author-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.author-glyph {
  flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-size: 11.5px; font-weight: 500; color: var(--a200);
  background: linear-gradient(to bottom, var(--photo-top), var(--bg)); box-shadow: 0 0 0 1px var(--divider);
}
.author-glyph.orb { box-shadow: none; background: var(--khala) center / contain no-repeat; }
.author-glyph .ph { font-size: 15px; color: var(--a300); }
.author-row.sm .author-glyph { width: 24px; height: 24px; }
.author-line { flex: 1; min-width: 0; font-size: 13px; color: var(--n300); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.author-line.khala { color: var(--a200); font-weight: 500; }
.author-time { flex: none; font-size: 12px; color: var(--n500); }
.under-review { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: var(--danger); line-height: 1.4; }
.under-review .ph { margin-top: 1px; }
.folded-note { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--n400); }

.post-footer { display: flex; align-items: center; gap: 2px; min-height: 44px; }
.vote-bar { display: inline-flex; align-items: center; }
.vote-bar.own { gap: 6px; padding: 0 4px; color: var(--n600); }
.vote { display: grid; place-items: center; width: 38px; height: 40px; border-radius: 10px; color: var(--n500); transition: color .12s, background-color .12s; }
.vote.up.on { color: var(--accent); }
.vote.down.on { color: var(--n400); }
@media (hover: hover) { .vote:hover { background: rgb(var(--glow-rgb) / .08); color: var(--text); } }
.vote-score { min-width: 18px; text-align: center; font-size: 13.5px; font-weight: 500; color: var(--n300); font-variant-numeric: tabular-nums; }
.vote-score.up { color: var(--accent); }
.vote-score.down { color: var(--n400); }
.reply-count { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 8px; border-radius: 10px; font-size: 13.5px; color: var(--n300); }
.reply-count .ph { color: var(--n400); }
@media (hover: hover) { button.reply-count:hover { background: rgb(var(--glow-rgb) / .08); } }
.topic-label { max-width: 46%; padding: 3px 9px; border-radius: 10px; border: 1px solid var(--divider); font-size: 11.5px; color: var(--n400); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.post-menu { color: var(--n400); }

.side-card { padding: 18px 18px 8px; border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow-sm); }
.community-about .sheet-title { font-size: 17px; }
.about-points { display: flex; flex-direction: column; gap: 14px; margin: 14px 0 6px; }
.about-points li { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; line-height: 1.5; color: var(--n200); }
.about-points .ph { color: var(--accent); margin-top: 1px; }
.side-card .about-points li { font-size: 13.5px; }
.community-about .link-row { min-height: 46px; border-top: 1px solid var(--n900); margin-top: 6px; }
.community-about .link-row .ph:last-child { color: var(--n500); }

/* ── A thread ────────────────────────────────────────────────────────────── */
.community-post > .header { width: 100%; max-width: 800px; margin-inline: auto; }
.thread-col { width: 100%; max-width: 760px; margin-inline: auto; padding: 4px 16px 24px; }
@media (min-width: 768px) { .thread-col { padding-inline: 28px; } }
.thread-post { display: flex; flex-direction: column; gap: 12px; }
.thread-post .author-glyph { width: 32px; height: 32px; font-size: 13px; }
.thread-text { font-size: 16.5px; font-weight: 400; line-height: 1.6; white-space: pre-line; overflow-wrap: anywhere; outline: none; }
.thread-text.khala { font-size: 20px; font-weight: 500; line-height: 1.4; }
.thread-summary { margin-top: 6px; padding: 12px 14px 14px; border-radius: var(--r-card); background: rgb(var(--glow-rgb) / .07); box-shadow: inset 0 0 0 1px var(--a800); }
.thread-summary h2 { font-size: 14.5px; font-weight: 500; color: var(--a200); }
.thread-summary .t-secondary { font-size: 12px; color: var(--n400); }
.thread-summary .content { font-size: 14.5px; line-height: 1.55; color: var(--n200); white-space: pre-line; }
.community-post .rule { margin: 14px 0 12px; }
.replies { display: flex; flex-direction: column; }
.reply { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-bottom: 1px solid var(--n900); }
.reply:last-child { border-bottom: 0; }
.reply-body { padding-inline-start: 32px; }
.reply-body > .content { font-size: 15px; line-height: 1.55; white-space: pre-line; overflow-wrap: anywhere; }
.reply-body .post-footer { margin-inline-start: -8px; }
.thread-composer { flex: none; background: var(--bg); padding: 4px 0 calc(10px + var(--safe-bottom)); box-shadow: 0 -1px 0 var(--n900); }
.thread-composer .thread-col { padding-block: 0; }
.reply-as { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 4px; border-radius: var(--r-base); font-size: 12.5px; color: var(--n400); text-align: start; }
.reply-as > .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-as-change { font-weight: 500; color: var(--accent); }
@media (hover: hover) { .reply-as:hover { background: rgb(var(--glow-rgb) / .06); } }

/* ── Compose ─────────────────────────────────────────────────────────────── */
.compose { display: flex; flex-direction: column; }
.compose-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.compose-head .sheet-title { margin: 0; }
.topic-choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.topic-choices .chip { min-height: 38px; }
.compose-text { min-height: 150px; max-height: 50vh; font-size: 16px; line-height: 1.55; resize: vertical; }
.note-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-card); background: rgb(var(--glow-rgb) / .06); }
.note-card .ph { color: var(--accent); margin-top: 2px; }
.note-card p { font-size: 13.5px; line-height: 1.45; color: var(--n300); }
.compose-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.dialog:has(> .compose) { width: calc(100% - 24px); max-width: 640px; max-height: calc(100dvh - 24px); }
@media (min-width: 900px) { .dialog:has(> .compose) { width: min(640px, calc(100vw - 48px)); padding: 24px 26px 18px; } }

/* ── Chats ───────────────────────────────────────────────────────────────── */
.chats-split { flex: 1; min-height: 0; display: flex; }
.chats-list, .chat-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.chats-list { flex: 1; }
.chat-pane { flex: 1; display: none; }
/* Phones: the list, or the chat on its own. */
.chats.at-chat .chats-list { display: none; }
.chats.at-chat .chat-pane { display: flex; }
/* From tablet width: both, side by side. */
@media (min-width: 900px) {
  .chats-list { flex: 0 0 340px; border-inline-end: 1px solid var(--n900); background: var(--surface); }
  .chats.at-chat .chats-list { display: flex; }
  .chat-pane, .chats.at-chat .chat-pane { display: flex; }
  .chats-list .tab-header { padding-inline: 20px; }
}
@media (min-width: 1280px) { .chats-list { flex-basis: 380px; } }
.chats-label { padding: 0 16px; margin: 16px 0 8px; }
@media (min-width: 900px) { .chats-label { padding-inline: 20px; } }
.chats-none { padding: 4px 16px 16px; font-size: 14px; color: var(--n400); }
.new-matches { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 6px 10px 14px; }
.new-matches::-webkit-scrollbar { display: none; }
.new-match {
  display: flex; flex-direction: column; align-items: center; gap: 6px; width: 84px; padding: 8px 4px; border-radius: var(--r-card);
  text-decoration: none; color: var(--text); font-size: 13px; line-height: 1.2;
}
.new-match > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.new-match.on { background: var(--a900); }
@media (hover: hover) { .new-match:not(.on):hover { background: rgb(var(--glow-rgb) / .06); } }
.conversations { display: flex; flex-direction: column; padding: 0 8px 16px; }
.conversation {
  display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 10px 10px; border-radius: 12px; text-decoration: none; color: var(--text);
}
.conversation.on { background: var(--a900); }
@media (hover: hover) { .conversation:not(.on):hover { background: rgb(var(--glow-rgb) / .06); } }
.conversation-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.conversation-top { display: flex; align-items: baseline; gap: 8px; }
.conversation-name { flex: 1; min-width: 0; font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-top time { flex: none; font-size: 12px; color: var(--n500); }
.conversation-preview { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--n400); line-height: 1.3; }
.conversation-preview .content { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: start; }
.conversation.unread .conversation-preview { color: var(--text); }
.chat-pick { color: var(--n400); }

.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-head {
  display: flex; align-items: center; gap: 4px; min-height: 64px; padding: calc(var(--safe-top) + 6px) 10px 8px 4px; box-shadow: 0 1px 0 var(--n900);
}
:root[dir="rtl"] .chat-head { padding: calc(var(--safe-top) + 6px) 4px 8px 10px; }
@media (min-width: 900px) {
  .chat-head { padding: 10px 16px 10px 20px; min-height: 72px; }
  :root[dir="rtl"] .chat-head { padding: 10px 20px 10px 16px; }
  .chat-back { display: none !important; }
}
.chat-who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 4px 6px; border-radius: var(--r-base); text-decoration: none; color: var(--text); }
@media (hover: hover) { .chat-who:hover { background: rgb(var(--glow-rgb) / .06); } }
.chat-who-text { min-width: 0; display: flex; flex-direction: column; }
.chat-who-name { font-size: 16px; font-weight: 500; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-who-sub { font-size: 12px; color: var(--n400); line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wali-chip {
  display: inline-flex; align-items: center; gap: 5px; max-width: 140px; min-height: 30px; margin: 0 4px; padding: 4px 10px; border-radius: 6px;
  background: var(--a800); color: var(--a100); font-size: 11.5px; line-height: 1.3;
}
.wali-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat .thread { flex: 1; }
.bubble.mine { display: flex; flex-direction: column; }
.bubble-read { align-self: flex-end; margin-top: 2px; font-size: 11px; color: var(--n500); }
.wali-banner {
  display: flex; gap: 10px; align-items: flex-start; padding: 14px 16px; margin-bottom: 6px; border-radius: var(--r-card);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.wali-banner > .ph { color: var(--accent); margin-top: 1px; }
.wali-banner h3 { font-size: 15px; font-weight: 500; }
.wali-banner p { margin-top: 2px; font-size: 13.5px; color: var(--n400); line-height: 1.45; }
.chat-composer { padding: 6px 0 calc(12px + var(--safe-bottom)); }
.chat-composer .composer { padding-inline: 12px; }
.refusal-note {
  display: flex; gap: 10px; align-items: flex-start; margin: 0 16px 8px; padding: 10px 12px; border-radius: 14px;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--a800);
}
.refusal-note .ph { color: var(--a300); margin-top: 1px; }
.refusal-note p { font-size: 13.5px; line-height: 1.4; color: var(--n200); }
.chat-ended { padding: 12px 16px calc(16px + var(--safe-bottom)); font-size: 14px; color: var(--n400); max-width: 760px; width: 100%; margin: 0 auto; }
