/* Conversation frame: one quiet surface, profiles at the edges, actions at the bottom. */
.chat-page .chat-v2 { --frame-color:#166534; --frame-tint:#edf4ef; display:block; min-width:0; }
.chat-v2[data-frame="green"] { --frame-color:#166534; --frame-tint:#edf4ef; }
.chat-v2[data-frame="blue"] { --frame-color:#1d4ed8; --frame-tint:#eff4ff; }
.chat-v2[data-frame="red"] { --frame-color:#7f1d1d; --frame-tint:#fcf0f0; }
.chat-v2[data-frame="black"] { --frame-color:#000000; --frame-tint:#f0f0f0; }
.chat-v2 *, .chat-page dialog * { box-sizing:border-box; }
.chat-v2 [hidden], .chat-page dialog [hidden] { display:none !important; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; }
.chat-v2 button, .chat-page dialog button { font:inherit; cursor:pointer; border:1px solid var(--border-color); border-radius:8px; background:var(--card-bg); color:var(--text-color); padding:8px 12px; }
.chat-v2 button:hover, .chat-page dialog button:hover { border-color:var(--frame-color,var(--link-color)); }
.chat-v2 button:disabled { opacity:.45; cursor:default; }
.chat-v2 :focus-visible, .chat-page dialog :focus-visible { outline:2px solid var(--link-color); outline-offset:3px; }
.chat-presence-bar { display:flex; align-items:center; gap:16px; padding:0 8px 12px; flex-wrap:wrap; font-size:12px; }
.chat-presence-bar .chat-status-indicator { margin:0; padding:0; border:0; display:flex; align-items:center; gap:8px; }
.chat-frame-colors { display:flex; align-items:center; gap:8px; }
.chat-frame-colors button { width:19px; height:19px; padding:0; border-radius:50%; background:var(--swatch); border:2px solid var(--card-bg); outline:1px solid var(--border-color); }
.chat-frame-colors button[aria-pressed="true"] { outline:2px solid var(--swatch); outline-offset:2px; }
.chat-sound { margin-left:auto; display:flex; align-items:center; gap:4px; color:var(--sub-text); }
.chat-v2 .chat-shell { display:grid; grid-template-columns:148px minmax(0,1fr) 160px; grid-template-rows:minmax(360px,1fr) auto; gap:0 12px; border:1px solid var(--frame-color); border-radius:16px; padding:12px; background:var(--card-bg); height:clamp(640px,calc(100dvh - 170px),820px); }
.chat-v2 .chat-profile { display:flex; flex-direction:column; grid-row:1; min-height:0; border:0; border-radius:0; background:transparent; gap:12px; }
.chat-v2 .peer-profile { grid-column:1; }
.chat-v2 .self-profile { grid-column:3; }
.chat-v2 .chat-profile details { display:flex; flex-direction:column; min-height:0; flex:1; border:1px solid var(--border-color); border-radius:9px; overflow:auto; background:var(--card-bg); }
.chat-v2 .profile-heading { background:var(--frame-color); color:#fff; font-size:11px; line-height:1.2; padding:8px 10px; border:0; list-style:none; cursor:default; }
.chat-v2 .profile-heading::-webkit-details-marker { display:none; }
.chat-v2 .profile-content { padding:12px 10px; font-size:12px; overflow-wrap:anywhere; }
.chat-v2 .profile-content h3 { font-size:13px; line-height:1.6; margin:0 0 12px; }
.chat-v2 .profile-content p { margin:8px 0; line-height:1.7; }
.chat-v2 .profile-interests { font-size:11px; line-height:1.7; }
.chat-v2 .profile-actions { display:grid; grid-template-columns:1fr; gap:6px; margin:20px 0 10px; }
.chat-v2 .profile-actions button { font-size:11px; padding:7px 6px; text-align:left; }
.chat-v2 .profile-avatar { width:100px; height:100px; flex:0 0 100px; margin:0 auto; border:1px solid var(--border-color); border-radius:12px; background:var(--card-bg); overflow:hidden; display:grid; place-items:center; font-size:10px; color:var(--sub-text); }
.chat-v2 .profile-avatar img { width:100%; height:100%; object-fit:contain; }
.chat-v2 .common-topic-option { display:flex; gap:3px; align-items:start; margin-top:14px; color:var(--sub-text); font-size:10px; }
.chat-post-proof { display:grid; gap:8px; font-size:10px; margin-top:12px; }
.chat-v2 .chat-main-area { grid-column:2; grid-row:1; display:flex; flex-direction:column; height:auto; min-height:0; overflow:hidden; border:0; background:var(--card-bg); }
.chat-v2 .chat-header-bar { padding:0 0 10px; gap:8px; background:transparent; min-height:28px; flex-wrap:wrap; border-bottom:1px solid var(--border-color); font-size:11px; }
.chat-v2 .chat-header-bar small { font-size:9px; margin-left:auto; }
.chat-context-actions { display:flex; gap:8px; font-size:10px; }
.chat-context-actions button { padding:2px 4px; background:transparent; border:0; font-size:10px; color:var(--link-color); }
.chat-v2 .chat-log { height:auto; min-height:0; max-height:none; flex:1; padding:18px 12px; gap:16px; background:var(--bg-color); }
.chat-v2 .chat-msg { max-width:calc(50% - 12px); min-width:0; }
.chat-v2 .chat-bubble { position:relative; padding:12px 14px; font-size:14px; line-height:1.7; border-radius:14px; overflow-wrap:anywhere; white-space:pre-wrap; }
.chat-v2 .chat-msg.other .chat-bubble { background:var(--card-bg); border:1px solid var(--border-color); border-bottom-left-radius:3px; }
.chat-v2 .chat-msg.self .chat-bubble { background:var(--frame-color); color:#fff; border:1px solid var(--frame-color); border-bottom-right-radius:3px; }
.chat-v2 .chat-msg.other .chat-bubble::after { content:''; position:absolute; left:-7px; bottom:7px; width:11px; height:11px; background:var(--card-bg); border-left:1px solid var(--border-color); border-bottom:1px solid var(--border-color); transform:skewY(-35deg); }
.chat-v2 .chat-msg.self .chat-bubble::after { content:''; position:absolute; right:-7px; bottom:7px; width:11px; height:11px; background:var(--frame-color); transform:skewY(35deg); }
.chat-v2 .chat-msg.system { align-self:center; width:100%; max-width:100%; padding:8px 12px; border:0; border-radius:10px; background:var(--header-bg); font-size:12px; line-height:1.8; }
.chat-v2 .chat-etiquette { text-align:left; padding:14px 16px; }
.chat-v2 .chat-etiquette strong { font-size:12px; font-weight:600; }
.chat-v2 .chat-etiquette p { margin:8px 0; }
.chat-v2 .chat-etiquette ol { padding-left:1.6em; margin:10px 0; }
.chat-v2 .chat-etiquette li { padding:2px 0; }
.chat-v2 .chat-ended { text-align:left; }
.chat-v2 .chat-ended p { margin:6px 0; }
.chat-v2 button.chat-inline-link { border:0; border-radius:0; background:transparent; padding:0; color:var(--link-color); text-decoration:underline; font-size:inherit; }
.chat-v2 .chat-live-line { min-height:24px; padding:2px 6px; font-size:10px; border:0; }
.chat-v2 .chat-composer { grid-column:1/-1; grid-row:2; display:grid; grid-template-columns:148px minmax(0,1fr) 160px; gap:10px 12px; padding-top:12px; align-items:stretch; }
.chat-v2 .chat-prompt-buttons { grid-column:2; display:flex; justify-content:flex-end; flex-wrap:wrap; gap:6px; margin:0; padding:0; }
.chat-prompt-buttons button { font-size:11px; padding:7px 10px; }
.chat-v2 .chat-session-button { grid-column:1; grid-row:2; color:#fff; background:var(--frame-color); border-color:var(--frame-color); font-weight:600; }
.chat-v2 .chat-session-button.is-ending { background:var(--card-bg); border-color:#bd6565; color:#a03d3d; }
.chat-v2 #chatInput { grid-column:2; grid-row:2; width:100%; min-width:0; min-height:72px; max-height:150px; padding:12px; resize:vertical; border:1px solid var(--border-color); border-radius:10px; font:inherit; font-size:16px; color:var(--text-color); background:var(--bg-color); line-height:1.6; }
.chat-v2 #btnChatSend { grid-column:3; grid-row:2; background:var(--frame-color); border-color:var(--frame-color); color:#fff; font-weight:600; }
.chat-page dialog { width:min(560px,calc(100vw - 32px)); max-height:85dvh; border:1px solid var(--border-color); border-radius:16px; padding:22px; background:var(--card-bg); color:var(--text-color); box-shadow:0 18px 60px #0003; font-size:13px; line-height:1.8; }
.chat-page dialog::backdrop { background:#17202b55; }
.chat-page .dialog-head { position:sticky; top:-22px; background:var(--card-bg); padding-bottom:12px; gap:16px; z-index:2; }
.chat-page .dialog-head h2 { font-size:16px; margin:0; }
.chat-page .topic-reader-dialog { width:min(740px,calc(100vw - 32px)); }
.topic-reader-post { padding:14px 0; border-bottom:1px solid var(--border-color); overflow-wrap:anywhere; }
.topic-reader-post p { line-height:1.9; margin:8px 0; }
.chat-page #interestTags { display:flex; flex-wrap:wrap; gap:8px; border:0; padding:8px 0 16px; }
.chat-page #interestTags button { background:var(--header-bg); }
.chat-page #interestTags button[aria-pressed="true"] { background:var(--active-bg); outline:1px solid var(--link-color); }
.chat-page #profileInterests { width:100%; margin:8px 0 16px; }
.chat-page #topicReaderBody .support-form { display:grid; gap:12px; }
.chat-page #topicReaderBody .support-form label { display:grid; gap:4px; }
.chat-page #topicReaderBody .support-form input,.chat-page #topicReaderBody .support-form textarea { width:100%; }
.chat-v2 .shared-topic-card { display:grid; white-space:normal; }
.chat-v2 .chat-msg.self .shared-topic-card { color:#fff; }
@media(min-width:1251px) { .chat-page .wrap { max-width:1680px; } .chat-page .layout { grid-template-columns:220px minmax(0,1fr); gap:20px; } }
@media(max-width:1000px) and (min-width:701px) { .chat-v2 .chat-shell { grid-template-columns:125px minmax(0,1fr) 135px; } .chat-v2 .chat-composer { grid-template-columns:125px minmax(0,1fr) 135px; } }
@media(max-width:700px) {
 .chat-page .chat-v2 { display:block; }
 .chat-presence-bar { gap:12px; padding:4px 4px 12px; font-size:10px; }
 .chat-sound { font-size:10px; }
 .chat-frame-colors { gap:7px; }
 .chat-frame-colors button { width:15px; height:15px; }
 .chat-v2 .chat-shell { grid-template-columns:repeat(2,minmax(0,1fr)); grid-template-rows:auto minmax(100px,1fr) auto; gap:10px; height:calc(100dvh - 140px); min-height:420px; max-height:850px; padding:10px; border-radius:12px; }
 .chat-v2 .chat-profile { grid-row:1; display:grid; grid-template-columns:minmax(0,1fr) 40px; gap:6px; align-items:start; }
 .chat-v2 .peer-profile { grid-column:1; }
 .chat-v2 .self-profile { grid-column:2; }
 .chat-v2 .chat-profile details { min-width:0; border-radius:7px; max-height:190px; }
 .chat-v2 .profile-heading { font-size:10px; padding:8px 6px; cursor:pointer; }
 .chat-v2 .profile-avatar { width:40px; height:40px; min-height:40px; flex-basis:40px; font-size:7px; margin:0; border-radius:8px; }
 .chat-v2 .profile-content { padding:8px; font-size:11px; }
 .chat-v2 .profile-content h3 { font-size:11px; }
 .chat-v2 .profile-actions { margin-top:10px; }
 .chat-v2 .profile-actions button { font-size:10px; }
 .chat-v2 .chat-main-area { grid-column:1/-1; grid-row:2; height:auto; min-height:0; }
 .chat-v2 .chat-header-bar { min-height:20px; padding-bottom:6px; font-weight:normal; }
 .chat-v2 .chat-header-bar small { display:none; }
 .chat-v2 .chat-log { height:auto; min-height:0; padding:12px 8px; gap:12px; }
 .chat-v2 .chat-msg { max-width:calc(50% - 8px); }
 .chat-v2 .chat-bubble { padding:9px 10px; font-size:13px; }
 .chat-v2 .chat-msg.system { max-width:100%; font-size:11px; line-height:1.8; }
 .chat-v2 .chat-etiquette { padding:10px; }
 .chat-v2 .chat-etiquette strong { font-size:11px; }
 .chat-v2 .chat-composer { grid-column:1/-1; grid-row:3; grid-template-columns:76px minmax(0,1fr) 52px; gap:8px 6px; padding-top:0; }
 .chat-v2 .chat-prompt-buttons { grid-column:1/-1; justify-content:flex-end; gap:4px; }
 .chat-v2 .chat-prompt-buttons button { font-size:10px; padding:7px 6px; }
 .chat-v2 .chat-session-button { font-size:10px; padding:8px 5px; }
 .chat-v2 #chatInput { min-height:64px; padding:8px; }
 .chat-v2 #btnChatSend { font-size:12px; padding:8px 4px; }
 .chat-page dialog { padding:16px; }
}

.topic-reader-post.is-verified-post { background:var(--active-bg); padding:14px; border-radius:10px; outline:1px solid var(--link-color); }

@media(max-width:700px) {
 .chat-page .top-inner { min-height:48px; padding:8px 16px; }
 .chat-page .top .header-themes, .chat-page .top .header-support, .chat-page .top .notification-bell { display:none; }
 .chat-page .logo-area { margin:0; }
 .chat-page .chat-profile details { max-height:150px; }
}

/* Dialog controls must override the shared .btn-sm white-text rule. */
.chat-page dialog button,
.chat-page dialog button:hover,
.chat-page dialog button:focus-visible,
.chat-page dialog button:active { color:var(--text-color) !important; }
.chat-page dialog button:hover { background:var(--header-bg); }

/* Match the reference frame width instead of stretching with a wide monitor. */
.chat-page .chat-v2 { width:1000px; max-width:100%; margin-inline:auto; }
.chat-page .wrap { max-width:1280px; }

/* The site theme supplies the frame color; no independent chat palette. */
.chat-page .chat-v2 { --frame-color:var(--active-bg); --frame-tint:var(--active-bg); }
.chat-v2 .chat-shell { border-color:var(--border-color); }
.chat-v2 .profile-heading,
.chat-v2 .chat-msg.self .chat-bubble,
.chat-v2 .chat-session-button,
.chat-v2 #btnChatSend { color:var(--text-color); }
.chat-v2 .chat-session-button.is-ending { color:var(--text-color); background:var(--active-bg); border-color:var(--border-color); }
