/* =================== CHAT · HUB · BELL · FRIENDS =================== */
.chat-page { max-width: 1240px; padding-bottom: 20px; }
.hub-head { margin-bottom: 14px; }
.chatapp { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - 140px); min-height: 480px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.hub-head + #chat-root .chatapp { height: calc(100vh - 220px); }
.ptab-body .chatapp { height: calc(100vh - 210px); }

/* list */
.ch-side { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-height: 0; background: rgba(0,0,0,.12); }
.ch-side-head { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.ch-search { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; color: var(--ink); }
.ch-call.wide { margin: 10px 12px 0; }
.ch-list { overflow-y: auto; flex: 1; padding: 6px 6px 12px; }
.ch-sec { font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--accent2); padding: 14px 10px 6px; }
.ch-none { padding: 20px 12px; }
.ch-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; background: none; border: 0; text-align: left; color: var(--ink); }
.ch-item:hover { background: rgba(255,255,255,.04); }
.ch-item.on { background: rgba(155,77,255,.2); }
.ch-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ch-item-top { display: flex; justify-content: space-between; gap: 8px; }
.ch-item-top b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14.5px; }
.ch-item-top small { color: var(--mute); font-size: 11.5px; flex: 0 0 auto; }
.ch-item-proj { font-size: 11px; color: var(--accent2); font-weight: 700; }
.ch-item-prev { color: var(--mute); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-item.unread .ch-item-prev { color: var(--ink); font-weight: 700; }
.ch-badge { flex: 0 0 auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 800; font-style: normal; display: grid; place-items: center; }
.ch-ico { display: inline-grid; place-items: center; width: var(--s); height: var(--s); flex: 0 0 var(--s); border-radius: 12px; background: var(--card2); border: 1px solid var(--line); font-size: calc(var(--s) * .5); }
.ch-ico.big { --s: 72px; border-radius: 20px; }

/* conversation */
.ch-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ch-empty { margin: auto; }
.ch-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: rgba(0,0,0,.15); }
.ch-head-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ch-head-text b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-head-text small { color: var(--mute); font-size: 12.5px; }
.ch-back { display: none; background: none; border: 0; color: var(--ink); font-size: 30px; line-height: 1; padding: 0 6px 4px 0; }
.ch-msgs { flex: 1; overflow-y: auto; padding: 14px 14px 8px; display: flex; flex-direction: column; }
.ch-loading { margin: auto; }
.ch-older { align-self: center; margin-bottom: 10px; }
.ch-hello { margin: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 30px; }
.msg-day { text-align: center; margin: 14px 0 8px; }
.msg-day span { font-size: 11.5px; font-weight: 800; color: var(--mute); background: var(--card2); border: 1px solid var(--line); padding: 3px 10px; border-radius: 999px; }
.msg { position: relative; display: flex; gap: 10px; padding: 2px 6px; border-radius: 10px; }
.msg.first { margin-top: 10px; }
.msg:hover { background: rgba(255,255,255,.03); }
.msg-av { width: 36px; flex: 0 0 36px; }
.msg-col { flex: 1; min-width: 0; }
.msg-meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 1px; }
.msg-meta b { font-size: 14.5px; }
.msg.mine .msg-meta b { color: var(--accent2); }
.msg-meta small { color: var(--mute); font-size: 11.5px; }
.msg-b { font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.msg-text a { color: #9ddcff; text-decoration: underline; }
.msg-edited { font-size: 11px; color: var(--mute); margin-left: 4px; }
.msg-del { color: var(--mute); font-style: italic; font-size: 13.5px; }
.msg-reply { font-size: 12.5px; color: var(--mute); border-left: 3px solid var(--accent); padding: 2px 8px; margin: 2px 0 4px; background: rgba(155,77,255,.08); border-radius: 0 6px 6px 0; }
.msg-img { display: block; padding: 0; border: 0; background: var(--card2); border-radius: 12px; overflow: hidden; margin: 4px 0; max-width: min(360px, 100%); min-height: 80px; }
.msg-img img { display: block; width: 100%; height: auto; max-height: 360px; object-fit: cover; }
.mention { color: #c79bff; background: rgba(155,77,255,.18); padding: 0 3px; border-radius: 4px; font-weight: 700; }
.mention.me { color: #ffd36b; background: rgba(255,182,39,.18); }
.msg-acts { position: absolute; right: 8px; top: -12px; display: none; gap: 2px; background: var(--card2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; box-shadow: var(--shadow); }
.msg:hover .msg-acts { display: flex; }
.msg-acts button { background: none; border: 0; padding: 4px 7px; border-radius: 6px; font-size: 13px; color: var(--ink); }
.msg-acts button:hover { background: rgba(255,255,255,.08); }

/* composer */
.ch-compose { position: relative; border-top: 1px solid var(--line); padding: 10px 12px; background: rgba(0,0,0,.15); }
.ch-row { display: flex; align-items: flex-end; gap: 8px; }
.ch-row textarea { flex: 1; resize: none; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; color: var(--ink); font-size: 15px; max-height: 160px; line-height: 1.4; }
.ch-row textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.ch-photo { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line); font-size: 18px; cursor: pointer; flex: 0 0 auto; }
.ch-send { width: 46px; height: 42px; padding: 0; font-size: 18px; border-radius: 12px; }
.ch-replybar { font-size: 13px; color: var(--mute); padding: 0 4px 8px; display: flex; gap: 8px; align-items: center; }
.ch-replybar button { margin-left: auto; background: none; border: 0; color: var(--mute); }
.ch-readonly { border-top: 1px solid var(--line); padding: 14px; text-align: center; color: var(--mute); font-weight: 700; }
.ch-mentions { position: absolute; left: 12px; right: 12px; bottom: calc(100% - 4px); background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; box-shadow: var(--shadow); z-index: 3; }
.ch-mentions button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 8px; border: 0; background: none; border-radius: 8px; color: var(--ink); text-align: left; }
.ch-mentions button.on, .ch-mentions button:hover { background: rgba(155,77,255,.2); }
.ch-mentions small { color: var(--mute); }

/* modal & pickers */
.modal { position: fixed; inset: 0; z-index: 2147482600; background: rgba(4,2,10,.75); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card { width: min(460px, 100%); max-height: 88vh; overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; box-shadow: var(--shadow); }
.modal-card.wide { width: min(600px, 100%); }
.modal-card h3 { margin-bottom: 12px; }
.pk-search { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; color: var(--ink); margin-bottom: 8px; font-size: 15px; }
.pk-list { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin-bottom: 14px; }
.pk-list.static { max-height: 340px; }
.pk-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; cursor: pointer; }
.pk-row:hover { background: rgba(255,255,255,.04); }
.pk-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.emoji-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.emoji-row button { width: 40px; height: 40px; border-radius: 10px; background: var(--card2); border: 1px solid var(--line); font-size: 19px; }
.emoji-row button.on { border-color: var(--accent); background: rgba(155,77,255,.25); }
.imgview img { width: 100%; max-height: 70vh; object-fit: contain; border-radius: 10px; margin-bottom: 10px; }

/* bell */
.bell-wrap { position: relative; }
.bell { position: relative; width: 40px; height: 40px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line); font-size: 17px; display: grid; place-items: center; }
.bell .pip { position: absolute; top: -5px; right: -6px; margin: 0; }
.bell-panel { position: absolute; right: 0; top: calc(100% + 8px); width: min(380px, 92vw); max-height: 70vh; overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); z-index: 70; }
.bell-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); }
.bell-item { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.bell-item:hover { background: rgba(255,255,255,.03); }
.bell-item.new { background: rgba(155,77,255,.1); }
.bell-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 13.5px; }
.bell-text span { color: var(--mute); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bell-text small { color: var(--mute); font-size: 11.5px; }
.pip.soft { background: var(--accent); }

/* friends */
.friend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.friend { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; text-align: center; }
.friend:hover { border-color: var(--accent2); }
.friend small { font-size: 11.5px; }
.pf-fr { margin: 0; white-space: nowrap; }

@media (max-width: 760px) {
  .chat-page { padding: 8px 6px 90px; }
  .hub-head { padding: 4px 8px; }
  .hub-head h1 { font-size: 24px; }
  .chatapp, .hub-head + #chat-root .chatapp, .ptab-body .chatapp { grid-template-columns: 1fr; height: calc(100dvh - 150px); border-radius: 12px; }
  .hub-head + #chat-root .chatapp { height: calc(100dvh - 210px); }
  .ptab-body .chatapp { height: calc(100dvh - 120px); }
  .chatapp .ch-main { display: none; }
  .chatapp.show-main .ch-side { display: none; }
  .chatapp.show-main .ch-main { display: flex; }
  .ch-back { display: block; }
  .ch-row textarea { font-size: 16px; }
  .msg:hover .msg-acts { display: none; }
  .msg.act .msg-acts { display: flex; top: -14px; }
  .nav .nav-admin { display: none; }
  .bell { width: 36px; height: 36px; }
}

/* =================== POST BOARDS =================== */
.board { flex: 1; overflow-y: auto; padding: 14px 16px 30px; }
.board-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.board-bar .seg.mini { margin: 0 0 0 auto; }
.seg.mini { display: flex; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg.mini button { background: none; border: 0; color: var(--mute); font-weight: 800; font-size: 13px; padding: 6px 12px; border-radius: 7px; }
.seg.mini button.on { background: #fff; color: #14082a; }
.board-feed { display: flex; flex-direction: column; gap: 12px; max-width: 760px; margin: 0 auto; }
.post-card, .post-full { background: var(--card2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.post-card { cursor: pointer; transition: border-color .15s, transform .15s; }
.post-card:hover { border-color: var(--accent2); transform: translateY(-1px); }
.post-full { max-width: 760px; margin: 0 auto; }
.post-by { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.post-by > div { display: flex; flex-direction: column; }
.post-by small { color: var(--mute); font-size: 12px; }
.post-pin { margin-left: auto; font-size: 12px; font-weight: 800; color: var(--gold); }
.post-title { font-family: var(--display); font-size: 18px; margin: 4px 0 6px; line-height: 1.25; }
h2.post-title { font-size: 24px; }
.post-excerpt { color: #ddd0f5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.post-body { font-size: 16px; line-height: 1.55; margin-bottom: 8px; overflow-wrap: anywhere; }
.post-body a, .post-excerpt a, .comment a { color: #9ddcff; text-decoration: underline; }
.post-img { margin: 10px 0; border-radius: 12px; overflow: hidden; background: var(--bg); }
.post-img img { display: block; width: 100%; max-height: 520px; object-fit: cover; }
.post-full .post-img img { object-fit: contain; max-height: 640px; }
.post-ytthumb { position: relative; margin: 10px 0; border-radius: 12px; overflow: hidden; aspect-ratio: 16/9; background: #000; }
.post-ytthumb img { width: 100%; height: 100%; object-fit: cover; opacity: .85; }
.post-ytthumb span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 44px; color: #fff; text-shadow: 0 4px 20px rgba(0,0,0,.6); }
.post-yt { margin: 10px 0; aspect-ratio: 16/9; border-radius: 12px; overflow: hidden; background: #000; }
.post-yt iframe { width: 100%; height: 100%; border: 0; }
.post-acts { display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.pa-like { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; color: var(--ink); font-size: 14px; }
.pa-like.on { border-color: #ff5c8a; background: rgba(255,92,138,.12); }
.pa-who { background: none; border: 0; color: var(--mute); font-size: 13px; text-decoration: underline; padding: 0; }
.pa-com { color: var(--mute); font-size: 14px; }
.pa-com b, .pa-like b { color: var(--ink); }
.comments { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.board > .sect { max-width: 760px; margin-left: auto; margin-right: auto; }
.comment { display: flex; gap: 10px; background: rgba(255,255,255,.03); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; overflow-wrap: anywhere; }
.c-meta { display: flex; align-items: baseline; gap: 8px; }
.c-meta small { color: var(--mute); font-size: 11.5px; }
.c-del { margin-left: auto; background: none; border: 0; opacity: .5; }
.c-del:hover { opacity: 1; }
.c-compose { max-width: 760px; margin: 14px auto 0; display: flex; gap: 8px; align-items: flex-end; }
.c-compose textarea { flex: 1; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; color: var(--ink); font-size: 15px; resize: vertical; }
@media (max-width: 760px) {
  .board { padding: 10px 8px 30px; }
  .c-compose textarea { font-size: 16px; }
  h2.post-title { font-size: 20px; }
}
.post-card .post-ytthumb, .post-card .post-img { max-width: 520px; }
.post-card .post-img img { max-height: 340px; }
.post-tags { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.post-tags .post-pin { margin-left: 0; }
.post-aud { font-size: 11.5px; font-weight: 800; padding: 3px 8px; border-radius: 999px; background: rgba(155,77,255,.16); color: var(--accent2); white-space: nowrap; }
.post-aud.lock { background: rgba(255,182,39,.14); color: var(--gold); }
.type-pick { width: fit-content; }
.modal { padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: max(16px, env(safe-area-inset-bottom)); }
@media (max-width: 760px) {
  .chatapp, .ptab-body .chatapp { height: calc(100dvh - 150px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
  .hub-head + #chat-root .chatapp { height: calc(100dvh - 210px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
  .ptab-body .chatapp { height: calc(100dvh - 120px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
}
