/* /chat/<channel> (Gary approved the mock-up, Nov 13). Computers: the regular chat with a Back to the Fringe link.
   Phones: a full-screen chat like an Instagram group chat. The header has back, SGTV, the channel name and the menu, with
   the pinned message and "here now" under it. Only the messages scroll, and the message box is a thin bar at the bottom. */
.chat-head { display:none; }
body.chat-app .fringe-back { display:inline-flex; align-items:center; gap:6px; margin:4px 0 12px; padding:7px 14px 7px 10px; border:1px solid #444; border-radius:999px; color:#eee; font:700 .85rem Arial,Helvetica,sans-serif; text-decoration:none; background:#111; }
body.chat-app .fringe-back:hover { border-color:#ff3b2b; color:#fff; }

@media (max-width:991.98px) {
    html:has(body.chat-app), body.chat-app { height:100%; overflow:hidden; overscroll-behavior:none; }
    body.chat-app { --chat-head:56px; background:#070707; }
    body.chat-app .site-header { min-height:0; height:calc(var(--chat-head) + env(safe-area-inset-top,0px)); padding-top:env(safe-area-inset-top,0px); background:rgba(7,7,7,.88); -webkit-backdrop-filter:blur(10px); backdrop-filter:blur(10px); border-bottom:1px solid #1d1d1d; }
    body.chat-app .site-header .navbar { height:var(--chat-head); padding-block:0; }
    body.chat-app .site-header .navbar-brand, body.chat-app .site-header > .live-sign { display:none; }
    body.chat-app .site-header .navbar-toggler { margin-left:auto; width:42px; height:36px; padding:0; display:grid; place-items:center; }
    body.chat-app .site-header .navbar-toggler-icon { width:22px; height:22px; }
    body.chat-app .chat-head { position:absolute; left:0; right:70px; top:env(safe-area-inset-top,0px); height:var(--chat-head); display:flex; align-items:center; gap:8px; padding-left:max(6px,env(safe-area-inset-left,0px)); z-index:3; pointer-events:none; }
    body.chat-app .chat-head > * { pointer-events:auto; }
    body.chat-app .chat-back { display:grid; place-items:center; width:36px; height:40px; color:#f2f2f2; }
    body.chat-app .chat-logo { font-family:Grotters,Anton,Impact,sans-serif; font-size:27px; line-height:1; color:#ff4433; text-shadow:var(--neon-glow); text-decoration:none; margin-left:4px; flex:none; }
    body.chat-app .chat-title { position:absolute; left:50%; transform:translateX(-50%); display:flex; align-items:center; gap:4px; max-width:46vw; border:0; background:none; color:#fff; font:700 16px Arial,Helvetica,sans-serif; padding:8px 4px; }
    body.chat-app .chat-title-text { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
    body.chat-app .chat-title svg { flex:none; color:#aaa; }
    body.chat-app main.page-main { position:fixed; top:calc(var(--chat-head) + env(safe-area-inset-top,0px)); bottom:0; left:0; right:0; max-width:none; width:auto; margin:0; padding:0; }
    body.chat-app .fringe-back, body.chat-app #sg-messenger, body.chat-app .cm-tabs { display:none !important; }
    body.chat-app .chat-shell, body.chat-app .cm-frame, body.chat-app #community { height:100%; margin:0; padding:0; border:0; border-radius:0; background:#070707; box-shadow:none; }
    body.chat-app .community-layout { display:block; height:100% !important; min-height:0 !important; margin:0; border:0; border-radius:0; background:#070707; }
    body.chat-app .community-messages { height:100%; display:flex; flex-direction:column; min-height:0; }
    /* The pinned message and "N here now" sit in one line under the header; the title, topic and Pinned button are hidden here. */
    body.chat-app .cm-head { flex:none; flex-wrap:nowrap; gap:8px; padding:7px 14px; background:rgba(20,20,22,.9); border-bottom:1px solid #222; }
    body.chat-app .cm-head > div:first-child, body.chat-app #community-pins-toggle, body.chat-app .cm-pinbar-close, body.chat-app .cm-pinbar button + button { display:none !important; }
    body.chat-app #community-pinbar { flex:1; min-width:0; margin:0; padding:0; border:0; background:none; box-shadow:none; }
    body.chat-app #community-pinbar .cm-pinbar-open { display:block; width:100%; text-align:left; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; border:0; background:none; color:#ddd; font-size:13px; padding:0; }
    body.chat-app #community-pinbar .cm-pinbar-open::before { content:"📌 "; }
    body.chat-app #community-presence { flex:none; margin:0 0 0 auto; color:#5be38a; font-size:12px; white-space:nowrap; }
    body.chat-app #community-presence:not(:empty)::before { content:"● "; }
    body.chat-app #community-older { display:none !important; }
    body.chat-app #community-history { flex:1 1 auto; min-height:0; max-height:none; padding:8px 10px; -webkit-overflow-scrolling:touch; }
    /* Thin message bar like Instagram: the tools show until you type, then the red send arrow takes their place. */
    body.chat-app .cm-compose { flex:none; padding:6px 10px calc(8px + env(safe-area-inset-bottom,0px)); border-top:0; background:#070707; }
    body.chat-app .cm-box { align-items:center; gap:4px; border:0; border-radius:24px; background:#1c1c1f; padding:4px 5px 4px 14px; }
    body.chat-app .community .cm-box textarea { min-height:36px; padding:8px 0; font-size:16px; }
    body.chat-app .cm-box .cm-icon { width:34px; height:34px; color:#ddd; }
    body.chat-app .cm-box .cm-send { display:none; place-items:center; width:44px; height:34px; border:0; border-radius:17px; background:#ff3b2b; color:#fff; padding:0; }
    body.chat-app .cm-box.has-text .cm-send { display:grid; }
    body.chat-app .cm-box.has-text .cm-icon { display:none; }
    body.chat-app .cm-compose-extras { display:none; }
    body.chat-app .cm-compose-extras:has(#community-cancel:not([hidden])) { display:flex; }
    body.chat-app #community-status:empty { display:none; }
    /* Tapping the channel name: description and every channel, over a dimmed chat. */
    body.chat-app .community-channels { display:none !important; }
    html.chat-sheet-open body.chat-app .community-channels { display:flex !important; position:fixed; z-index:1060; top:calc(var(--chat-head) + env(safe-area-inset-top,0px) + 6px); left:10px; right:10px; max-height:70vh; overflow:auto; padding:14px 12px; border:0; border-radius:16px; background:#1c1c1f; box-shadow:0 12px 40px rgba(0,0,0,.7); }
    html.chat-sheet-open body.chat-app main.page-main::after { content:""; position:fixed; inset:0; z-index:1055; background:rgba(0,0,0,.55); }
    body.chat-app .community-channels h2 { display:none; }
    body.chat-app .chat-sheet-topic { margin:0 4px 10px; color:#bbb; font-size:13.5px; line-height:1.4; }
    body.chat-app .chat-sheet-label { margin:6px 4px; font:700 11px Arial,Helvetica,sans-serif; letter-spacing:.08em; text-transform:uppercase; color:#888; }
    body.chat-app .community-channels button { min-height:46px; border-top:1px solid #2a2a2e; border-radius:0; font-size:15px; }
    body.chat-app .community-channels button::before { content:none; }
    body.chat-app .community-channels button[aria-current=true] { color:#ff6a5c; font-weight:700; background:none; box-shadow:none; }
}
/* Checked on the live page (Nov 13): the site's other phone rules made these grids; the header row, thin bar and full-height
   message list need flex, and the list's script-set height cap is lifted so the bar sits at the very bottom. */
@media (max-width:991.98px) {
    body.chat-app .cm-head { display:flex !important; align-items:center; }
    body.chat-app #community-pinbar { order:1; }
    body.chat-app #community-presence { order:2; }
    body.chat-app .cm-box { display:flex !important; flex-wrap:nowrap !important; align-items:center; }
    body.chat-app .community .cm-box textarea { flex:1; min-width:0; height:36px; border:0 !important; background:none !important; box-shadow:none !important; outline:0 !important; }
    body.chat-app .chat-title { position:static !important; transform:none !important; flex:1; justify-content:center; min-width:0; max-width:none !important; }
    body.chat-app #community-history { flex:1 1 auto !important; height:auto !important; max-height:none !important; }
}
/* Computers (Gary, Nov 13): the chat fits the window with no page scroll, and the phone-only description and
   "Chat channels" label stay out of the channel list. */
.chat-sheet-topic, .chat-sheet-label { display:none; }
@media (max-width:991.98px) { .chat-sheet-topic:not([hidden]), .chat-sheet-label { display:block; } }
@media (min-width:992px) {
    html:has(body.chat-app), body.chat-app { overflow:hidden; }
    body.chat-app main.page-main { height:calc(100dvh - var(--header-h,72px)); display:flex; flex-direction:column; padding-bottom:16px; overflow:hidden; }
    body.chat-app .chat-shell { flex:1 1 auto; min-height:0; display:flex; flex-direction:column; }
    body.chat-app .chat-shell .cm-frame, body.chat-app .chat-shell #community { flex:1 1 auto; min-height:0; height:100%; }
    body.chat-app .community:is(:not([data-broadcast-id]),[data-broadcast-id=""]) .community-layout { height:100% !important; min-height:0 !important; margin:0; }
    body.chat-app .community-messages { display:flex; flex-direction:column; min-height:0; height:100%; }
    body.chat-app #community-history { flex:1 1 auto !important; min-height:0 !important; max-height:none !important; height:auto !important; }
}
/* Checked live (Nov 13): the site's phone channel strip laid the channel menu out sideways. In the menu it's one list, top to bottom. */
@media (max-width:991.98px) {
    html.chat-sheet-open body.chat-app .community-channels { flex-direction:column !important; align-items:stretch; }
    body.chat-app .community-channels #community-channels { display:flex !important; flex-direction:column !important; gap:0 !important; overflow:visible !important; }
    body.chat-app .community-channels #community-channels h3 { margin:4px 4px 2px; font-size:11px; letter-spacing:.08em; text-transform:uppercase; color:#888; }
    body.chat-app .community-channels button { width:100% !important; white-space:normal !important; }
}
/* Gary, Nov 13: on computers the Back to the Fringe pill is only as wide as its words, inside the chat box above Channels. */
body.chat-app .community-channels .fringe-back { display:inline-flex; width:max-content; max-width:100%; margin:0 0 14px; padding:6px 12px 6px 9px; font-size:.8rem; }
/* Gary, Nov 13: the phone chat's menu button is 15% smaller. */
@media (max-width:991.98px) {
    body.chat-app .site-header .navbar-toggler { width:36px !important; height:31px !important; }
    body.chat-app .site-header .navbar-toggler-icon { width:19px !important; height:19px !important; }
}

/* Gary, Nov 20 (the app on iPhone): the header and chat stay inside the part of the screen the keyboard leaves (chat-app.js) */
@media (max-width:991.98px) {
    body.chat-app .site-header, body.chat-app .chat-head { transform:translateY(var(--vv-top,0px)); }
    body.chat-app main.page-main { top:calc(var(--chat-head) + env(safe-area-inset-top,0px) + var(--vv-top,0px)); bottom:auto; height:calc(var(--vv-h,100dvh) - var(--chat-head) - env(safe-area-inset-top,0px)); }
    html.chat-kb body.chat-app .cm-compose { padding-bottom:6px; }
    /* Safari tab on iPhone: lift the message box above Safari's floating address pill (about 75px; the pill isn't part of the visible area we measure). */
    /* Nov 22: and in the home-screen app, iOS's floating ⌃ ⌄ ✓ bar (about 60px); chat-app.js sets --chat-kb-bar to 76px or 62px on iPhone. */
    html.chat-kb body.chat-app main.page-main { height:calc(var(--vv-h,100dvh) - var(--chat-head) - env(safe-area-inset-top,0px) - var(--chat-kb-bar,0px)); }
}
