/**
 * Community — Discord-dark app styles (2026-08-11).
 *
 * In-house per the package rule; loaded by shell-stocks-community.php. The
 * shell fork paints the frame (--cm-* tokens defined there); this file is the
 * interior. Palette: chat #313338 · panel #2B2D31 · deep #1E1F22 · hover
 * #2E3035 · active #404249 · input #383A40 · text #DBDEE1 · muted #949BA4.
 * Accent stays Delvantic emerald, not blurple — we mimic the shape, keep the
 * brand.
 */

/* ── App frame ─────────────────────────────────────────────────────────── */
/* No in-page channel panel (the sidebar Community dropdown is the switcher) —
   the app is one full-width room. Every link in the chain carries BOTH flex
   and height:100% so the composer reaches the floor even if one ancestor's
   flex context misresolves — the band-under-the-composer bug (2026-08-11). */
.cm-app  { flex: 1 1 auto; min-height: 0; height: 100%; display: flex; flex-direction: column; }
.cm-chat { flex: 1 1 auto; min-height: 0; height: 100%; display: flex; flex-direction: column; }

/* ── Room ──────────────────────────────────────────────────────────────── */
.cm-room { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; background: var(--cm-bg-chat); }
.cm-roomhead { display: flex; align-items: center; gap: 8px; padding: 12px 16px;
    border-bottom: 1px solid var(--cm-line); box-shadow: 0 1px 0 rgba(0,0,0,.12); }
.cm-roomhash { font-size: 20px; color: var(--cm-text-muted); }
.cm-roomname { font-size: 15px; font-weight: 700; color: var(--cm-text-strong); }
.cm-roomtopic { font-size: 13px; color: var(--cm-text-muted); margin-left: 8px; padding-left: 12px;
    border-left: 1px solid var(--cm-bg-active); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Ticker lens pill (abilities/tickers/) — the room-is-filtered indicator. */
.cm-lens { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800;
    color: var(--cm-accent-soft); background: rgba(5,150,105,.16); border: 1px solid rgba(52,211,153,.35);
    border-radius: 999px; padding: 2px 6px 2px 11px; }
.cm-lens-clear { background: none; border: 0; color: var(--cm-accent-soft); font-size: 15px; line-height: 1;
    cursor: pointer; padding: 0 3px; }
.cm-lens-clear:hover { color: var(--cm-text-strong); }

/* Cashtag chips inside message bodies (abilities/tickers/). */
.cm-ticker-chip { display: inline-block; background: rgba(5,150,105,.16); border: 1px solid rgba(52,211,153,.3);
    color: var(--cm-accent-soft); font-size: 13px; font-weight: 700; border-radius: 6px; padding: 0 6px;
    margin: 0 1px; cursor: pointer; line-height: 1.4; vertical-align: baseline; }
.cm-ticker-chip:hover { background: rgba(5,150,105,.3); color: #fff; }

/* ── Feed + messages ───────────────────────────────────────────────────── */
/* Messages anchor to the BOTTOM (Discord behavior): flex column whose first
   message takes margin-top:auto, so a short conversation sits down by the
   composer instead of floating at the top — and unlike justify-content:flex-end
   this keeps overflow scrolling working once the channel fills up. */
.cm-feed { flex: 1 1 auto; overflow-y: auto; padding: 18px 0 20px; display: flex; flex-direction: column; }
.cm-feed > :first-child { margin-top: auto; }
/* TWO-ROW anatomy (2026-08-13 DOM rework, William): .cm-msg is a block —
   row 1 = .cm-msg-meta (avatar + author + time + …), row 2 = .cm-msg-body,
   full width, flush under the meta strip. */
/* margin stays LONGHAND on purpose (a shorthand would fight the ticker
   room's cascade indent, which also rides margin-left — its rule wins via
   the .cm-msg.cm-msg-child specificity bump in community-frame.css). */
.cm-msg { position: relative; display: block; padding: 2px 16px; margin-top: 14px; margin-left: 15px; }
.cm-msg-compact { margin-top: 2px; }
.cm-msg:hover { background: var(--cm-bg-hover); }

.cm-msg-meta { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cm-avatar { flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center;
    justify-content: center; font-size: 13px; font-weight: 700; color: #fff; user-select: none; overflow: hidden; }
.cm-avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cm-msg-author { font-size: 15px; font-weight: 600; color: var(--cm-text-strong); }
.cm-msg-engine .cm-msg-author { color: var(--cm-accent-soft); }
.cm-msg-enginetag { font-size: 9px; font-weight: 800; letter-spacing: .05em; padding: 1px 6px; border-radius: 5px;
    background: rgba(5,150,105,.22); color: var(--cm-accent-soft); border: 1px solid rgba(52,211,153,.35);
    text-transform: uppercase; }
.cm-msg-time { font-size: 11.5px; color: var(--cm-text-muted); }
/* Admin fingerprint — top-right of the meta row; quiet until hovered. */
.cm-msg-ref { margin-left: auto; background: none; border: 0; padding: 2px 6px; cursor: pointer;
    color: var(--cm-text-muted); opacity: .45; font-size: 13px; border-radius: 6px; }
.cm-msg:hover .cm-msg-ref { opacity: 1; }
.cm-msg-ref:hover { color: var(--cm-accent-soft); background: var(--cm-bg-hover); }
.cm-msg-ref-copied { color: var(--cm-accent-soft); opacity: 1; }
.cm-msg-body { font-size: 15px; line-height: 1.45; color: var(--cm-text); white-space: pre-wrap; word-break: break-word;
    margin-top: 5px; }
.cm-msg-compact .cm-msg-body { margin-top: 0; }
.cm-msg-removed { color: var(--cm-text-muted); font-style: italic; }

.cm-msg-replyctx { display: block; font-size: 12px; color: var(--cm-text-muted); margin: 4px 0 0;
    max-width: 560px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-msg-replyctx::before { content: ''; display: inline-block; width: 14px; height: 7px; margin: 0 6px 2px 2px;
    border-left: 2px solid var(--cm-bg-active); border-top: 2px solid var(--cm-bg-active); border-radius: 5px 0 0 0; }

/* The Twitter-flip card affordance: quiet chip in the meta row, revealed on
   hover — says the whole message is a click-through to its ticker room. */
/* Inline after the timestamp (NOT far-right — the hover toolbar owns that
   corner in the live app and was covering it). */
.cm-msg-openroom { margin-left: 4px; font-size: 11.5px; font-weight: 700; color: var(--cm-accent-soft);
    opacity: 0; white-space: nowrap; pointer-events: none; transition: opacity .12s; }
.cm-msg:hover .cm-msg-openroom { opacity: 1; }

/* Hover action toolbar — Discord's floating buttons, minimal. top:-4 (was
   -12, 2026-08-13): the overhang sat on the previous message's last line and
   stole its clicks. */
.cm-msg-actions { position: absolute; top: -4px; right: 18px; display: none; gap: 2px;
    background: var(--cm-bg-panel); border: 1px solid var(--cm-line); border-radius: 7px; padding: 2px 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.cm-msg:hover .cm-msg-actions { display: inline-flex; }
.cm-msg-action { background: none; border: 0; font-size: 12px; font-weight: 600; color: var(--cm-text-muted);
    cursor: pointer; padding: 3px 7px; border-radius: 5px; }
.cm-msg-action:hover { background: var(--cm-bg-hover); color: var(--cm-text-strong); }
.cm-msg-action-danger:hover { color: #f87171; }   /* --sc-red family, dark-adapted */
.cm-msg-action-ref i { font-size: 13px; }         /* uuid fingerprint (admin ref tool) */

/* ── Read-only + composer ──────────────────────────────────────────────── */
.cm-readonly { padding: 12px 16px; font-size: 13px; color: var(--cm-text-muted); background: var(--cm-bg-panel); }
.cm-composer { padding: 0 16px 18px; background: var(--cm-bg-chat); }
.cm-replybar { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--cm-text);
    background: var(--cm-bg-panel); border-radius: 8px 8px 0 0; padding: 6px 12px; }
.cm-replybar-cancel { margin-left: auto; background: none; border: 0; color: var(--cm-text-muted);
    font-size: 16px; cursor: pointer; line-height: 1; }
.cm-replybar-cancel:hover { color: var(--cm-text-strong); }
.cm-inputrow { display: flex; gap: 0; align-items: flex-end; background: var(--cm-bg-input); border-radius: 10px; }
.cm-replybar + .cm-inputrow { border-radius: 0 0 10px 10px; }
.cm-input { flex: 1 1 auto; resize: none; background: transparent; border: 0; outline: none;
    padding: 12px 14px; font-size: 15px; line-height: 1.4; color: var(--cm-text); }
.cm-input::placeholder { color: #6d6f78; }
.cm-send { background: none; border: 0; color: var(--cm-text-muted); font-size: 18px; padding: 10px 14px; cursor: pointer; }
.cm-send:hover { color: var(--cm-accent-soft); }
.cm-error { font-size: 12px; color: #f87171; min-height: 16px; padding-top: 4px; }

/* ── Dark scrollbars ───────────────────────────────────────────────────── */
.cm-feed::-webkit-scrollbar { width: 8px; }
.cm-feed::-webkit-scrollbar-thumb { background: var(--cm-bg-deep); border-radius: 4px; }
.cm-feed::-webkit-scrollbar-track { background: transparent; }

/* ── Admin dev-notes drawer (room-header right; body drops over the feed) ── */
.cm-devnotes { position: relative; margin-left: auto; }
.cm-devnotes summary { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; }
.cm-devnotes summary::-webkit-details-marker { display: none; }
/* Admin pill — the house role-badge admin blue, dark-adapted. */
.cm-devnotes-pill { font-size: 8.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    padding: 1px 6px; border-radius: 6px; background: rgba(29,78,216,.25); color: #93c5fd; border: 1px solid rgba(96,165,250,.4); }
.cm-devnotes-link { font-size: 12px; font-weight: 600; color: var(--cm-text-muted); }
.cm-devnotes summary:hover .cm-devnotes-link { color: var(--cm-text); }
/* The house dev-note widget is light-styled — it opens as a floating light
   panel below the header, over the dark feed. */
.cm-devnotes-body { position: absolute; right: 0; top: calc(100% + 10px); z-index: 30; width: min(520px, 80vw);
    max-height: 340px; overflow-y: auto; border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.45); }
.cm-devnotes-body .sc-dev-note { margin: 0; }

/* ── Mobile ────────────────────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    /* iOS zoom guard: Safari auto-zooms the whole page when a focused input's
       font-size is under 16px — the single most jarring mobile-chat bug. */
    .cm-input { font-size: 16px; }
}
@media (max-width: 700px) {
    .cm-roomtopic { display: none; }
    .cm-devnotes { display: none; }
    /* Tighter message anatomy for narrow columns. */
    .cm-msg { gap: 10px; padding: 2px 12px; margin-top: 11px; }
    .cm-avatar { flex-basis: 26px; width: 26px; height: 26px; font-size: 12px; }
    .cm-feed { padding: 12px 0 14px; }
    .cm-composer { padding: 0 12px 12px; }
    .cm-readonly, .cm-guestbar { padding: 10px 12px; }
}
/* Touch devices have no hover — the floating Reply/Remove/UUID toolbar would
   be unreachable. Show it inline, ghosted, on every message instead. */
@media (hover: none) {
    .cm-msg-actions { display: inline-flex; opacity: .55; }
    .cm-msg:active .cm-msg-actions { opacity: 1; }
}
