/* Simple Chat 0.7.7 — one complete stylesheet for this versioned web bundle. */

:root {
  color-scheme: light;
  --page: #f4f6fb; --surface: #ffffff; --subtle: #f8faff; --field: #f8faff;
  --ink: #1b2940; --muted: #64728a; --line: #dce3ef;
  --accent: #4059dc; --accent-hover: #3047c8; --button: #4059dc; --button-hover: #3047c8;
  --accent-soft: #eaf0ff; --accent-text: #29449c; --on-accent: #ffffff;
  --focus: #8c9df3; --placeholder: #68778e;
  --error: #a83440; --error-bg: #fff0f1; --success: #287558;
  --warning: #795e20; --warning-bg: #fff9ed; --overlay: #0a14285c;
  --bar-height: 76px; --app-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased;
}
:root[data-theme="blue"] {
  color-scheme: light;
  --page: #e8f1ff; --surface: #f9fcff; --subtle: #edf5ff; --field: #f1f7ff;
  --ink: #122d51; --muted: #476787; --line: #c4d7ef;
  --accent: #2457c5; --accent-hover: #1645ac; --button: #2457c5; --button-hover: #1645ac;
  --accent-soft: #dceaff; --accent-text: #174597; --focus: #6d9de2; --placeholder: #52708f;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #101722; --surface: #1a2433; --subtle: #182231; --field: #131d2b;
  --ink: #edf2fc; --muted: #b0bed2; --line: #39485d;
  --accent: #b8c6ff; --accent-hover: #d1dbff; --button: #4d63d2; --button-hover: #4055c0;
  --accent-soft: #293957; --accent-text: #c7d5ff; --focus: #94aaff; --placeholder: #a2b1c7;
  --error: #ffa7b2; --error-bg: #382430; --success: #83ddb6;
  --warning: #f2d796; --warning-bg: #332d21; --overlay: #030710b8;
}

:root[data-theme="dark_blue"] {
  color-scheme: dark;
  --page: #082f49; --surface: #0b3853; --subtle: #0d405d; --field: #082f49;
  --ink: #f0f9ff; --muted: #b5d9eb; --line: #39708e;
  --accent: #38bdf8; --accent-hover: #7dd3fc; --button: #38bdf8; --button-hover: #7dd3fc;
  --accent-soft: #155675; --accent-text: #a5edff; --on-accent: #082f49;
  --focus: #67e8f9; --placeholder: #b5d9eb;
  --error: #ffb8c3; --error-bg: #482b3a; --success: #8be5c4;
  --warning: #ffe2a4; --warning-bg: #423820; --overlay: #031523b8;
}

@supports (height: 100dvh) { :root { --app-height: 100dvh; } }
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; }
body { overflow: hidden; background: var(--page); color: var(--ink); }
button, input, textarea, select { font: inherit; touch-action: manipulation; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .5; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }
svg { display: block; width: 24px; height: 24px; flex: 0 0 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.noscript { position: fixed; z-index: 30; top: 10px; left: 10px; right: 10px; padding: 15px; text-align: center; background: var(--surface); color: var(--error); }

/* Persistent brand and language controls. */
.site-bar { height: var(--bar-height); max-width: 1220px; margin: 0 auto; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 18px; font-weight: 700; letter-spacing: -.4px; }
.brand > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; flex: 0 0 auto; width: 40px; height: 40px; border-radius: 12px; color: var(--accent); background: var(--accent-soft); }
.brand-mark svg { width: 25px; height: 25px; }
.site-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.language-picker { display: flex; align-items: center; gap: 7px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.language-icon { width: 17px; height: 17px; color: var(--accent); }
.language-picker select { max-width: 120px; min-height: 40px; border: 0; background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; }
.control-link { max-width: 145px; line-height: 1.35; }
.app { display: flex; align-items: center; justify-content: center; width: 100%; height: calc(var(--app-height) - var(--bar-height)); padding: 12px 28px 28px; overflow: hidden; }

/* Compact entry form; long registration forms scroll inside the viewport. */
.join-view { width: 100%; max-width: 360px; max-height: 100%; overflow-y: auto; padding: 8px 0 12px; scrollbar-width: thin; }
.join-view[data-mode="register"] { max-width: 360px; }
.join-card { padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 10px 30px #20365c08; }
.join-card h1 { margin: 0 0 16px; font-size: 22px; line-height: 1.25; letter-spacing: -.35px; font-weight: 600; }
.entry-links { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0 16px; margin-top: 8px; }
.entry-links button { min-height: 44px; padding: 6px 0; border: 0; border-radius: 4px; background: transparent; color: var(--accent); font-size: 13px; font-weight: 500; line-height: 1.4; cursor: pointer; }
.entry-links button:hover:not(:disabled) { text-decoration: underline; }
.entry-links .guest-entry-link { color: var(--muted); font-size: 12px; font-weight: 400; }
.field-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.field-label label, .form-field label { font-size: 13px; font-weight: 650; line-height: 1.45; }
.counter { flex: 0 0 auto; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.counter.over-limit { color: var(--error); font-weight: 650; }
.name-input, .form-field input, .form-field select { width: 100%; min-height: 49px; border: 1px solid var(--line); border-radius: 10px; background: var(--field); padding: 12px 13px; color: var(--ink); font-size: 16px; scroll-margin-block: 18px; }
.name-input:focus, .form-field input:focus, .form-field select:focus { border-color: var(--focus); background: var(--surface); }
.name-input::placeholder { color: var(--placeholder); font-size: 14px; }
.name-input[aria-invalid="true"], .form-field input[aria-invalid="true"], .form-field select[aria-invalid="true"], #messageInput[aria-invalid="true"] { border-color: var(--error); }
.field-hint { margin: 9px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.field-error { margin: 10px 0 0; color: var(--error); font-size: 12px; line-height: 1.5; }
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px; padding: 10px 18px; border: 0; border-radius: 10px; color: var(--on-accent); background: var(--button); font-size: 14px; font-weight: 650; transition: background .15s; }
.primary-button:hover:not(:disabled) { background: var(--button-hover); }
.join-button { width: 100%; min-height: 44px; margin-top: 16px; font-weight: 600; }
.join-button svg { width: 19px; height: 19px; }
.text-button { min-height: 40px; padding: 8px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--accent); font-size: 13px; font-weight: 600; }
.text-button:hover:not(:disabled) { background: var(--accent-soft); }
.entry-notice { padding: 10px 12px; margin: 0 0 16px; border-radius: 9px; background: var(--accent-soft); color: var(--muted); font-size: 12px; line-height: 1.55; }
.entry-notice.error { background: var(--error-bg); color: var(--error); }
.retry-session-button { margin: -8px 0 14px; }
.account-form { display: flex; flex-direction: column; gap: 12px; }
.account-form .join-button { margin-top: 2px; }
.account-form .field-error { margin: 0; }
.form-field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.form-field select { padding-right: 24px; }
.form-field .field-hint { margin-top: -1px; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: end; }
.join-card .form-field { gap: 6px; }
.join-card .name-input, .join-card .form-field input, .join-card .form-field select { min-height: 44px; padding: 10px 11px; border-radius: 8px; }
.optional-profile-details { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.optional-profile-details summary { min-height: 44px; padding: 12px 1px; color: var(--muted); font-size: 13px; line-height: 1.5; cursor: pointer; }
.optional-profile-details summary::marker { color: var(--accent); }
.optional-profile-details summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 5px; }
.optional-profile-fields { display: grid; gap: 12px; padding: 0 0 14px; }
.optional-profile-fields .form-grid { gap: 10px; }
.member-label { display: inline-block; padding: 2px 5px; border-radius: 5px; color: var(--accent-text); background: var(--accent-soft); font-size: 9px; font-weight: 600; line-height: 1.3; vertical-align: middle; white-space: nowrap; }

/* The conversation and Members are sibling columns inside one full-height card. */
.chat-panel { display: flex; flex-direction: column; position: relative; min-width: 0; min-height: 0; width: 100%; max-width: 1180px; height: 100%; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); overflow: hidden; box-shadow: 0 14px 48px #20365c06; }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 24px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.room-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.room-icon { display: grid; place-items: center; flex: 0 0 auto; width: 42px; height: 42px; border-radius: 13px; color: var(--accent); background: var(--accent-soft); }
.room-icon svg { width: 23px; height: 23px; }
.app-label { margin: 0 0 3px; color: var(--muted); font-size: 10px; letter-spacing: .2px; }
.room-heading h1 { margin: 0; font-size: 21px; line-height: 1.15; font-weight: 650; letter-spacing: -.6px; }
.header-actions { display: flex; align-items: center; gap: 18px; }
.connection-status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #aeb9ca; }
.connection-status[data-state="connected"] .status-dot { background: var(--success); }
.connection-status[data-state="reconnecting"] .status-dot, .connection-status[data-state="offline"] .status-dot { background: var(--warning); }
.leave-button { min-height: 38px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--muted); font-size: 12px; }
.leave-button:hover:not(:disabled) { color: var(--ink); background: var(--subtle); }
.lobby-layout { display: flex; flex: 1 1 auto; min-height: 0; }
.conversation-column { display: flex; flex: 1 1 auto; flex-direction: column; min-width: 0; min-height: 0; }
.connection-notice { flex: 0 0 auto; padding: 10px 24px; border-bottom: 1px solid var(--line); background: var(--warning-bg); color: var(--warning); font-size: 12px; line-height: 1.5; }
.conversation-frame { position: relative; display: flex; flex: 1 1 auto; min-height: 0; }
.message-scroll { width: 100%; min-height: 0; padding: 24px 24px 28px; overflow-y: auto; overscroll-behavior: contain; overflow-anchor: none; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.message-scroll:focus-visible { outline-offset: -4px; }
.message-list { display: flex; flex-direction: column; gap: 22px; list-style: none; margin: 0; padding: 0; }
.message { display: flex; flex-direction: column; align-items: flex-start; align-self: flex-start; max-width: 85%; min-width: 0; }
.message.own { align-items: flex-end; align-self: flex-end; }
.message-meta { display: flex; align-items: baseline; gap: 8px; max-width: 100%; margin: 0 2px 6px; }
.message.own .message-meta { flex-direction: row-reverse; }
.message-name { overflow-wrap: anywhere; color: var(--muted); font-size: 11px; font-weight: 650; }
.message-time { color: var(--muted); font-size: 10px; white-space: nowrap; }
.message-body { margin: 0; min-width: 0; max-width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 4px 14px 14px; background: var(--subtle); font-size: 14px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.own .message-body { color: var(--accent-text); background: var(--accent-soft); border-color: var(--line); border-radius: 14px 4px 14px 14px; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100%; text-align: center; padding: 28px 12px; }
.empty-icon { display: grid; place-items: center; width: 62px; height: 62px; margin-bottom: 18px; border-radius: 20px; background: var(--subtle); color: var(--accent-text); }
.empty-icon svg { width: 29px; height: 29px; }
.empty-state h2 { margin: 0 0 8px; color: var(--muted); font-size: 17px; font-weight: 600; letter-spacing: -.3px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.latest-button { position: absolute; z-index: 2; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 9px; min-height: 37px; padding: 7px 14px; border: 1px solid var(--line); border-radius: 30px; background: var(--surface); box-shadow: 0 4px 18px #253c7012; color: var(--accent); font-size: 12px; font-weight: 600; white-space: nowrap; }
.composer { flex: 0 0 auto; padding: 17px 24px 15px; border-top: 1px solid var(--line); background: var(--surface); }
.composer-row { display: flex; gap: 10px; align-items: flex-end; }
#messageInput { display: block; flex: 1 1 auto; min-width: 0; width: 100%; height: 46px; min-height: 46px; max-height: 140px; resize: none; padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--field); color: var(--ink); font-size: 16px; line-height: 21px; scrollbar-width: thin; }
#messageInput::placeholder { color: var(--placeholder); font-size: 14px; }
#messageInput:focus { background: var(--surface); border-color: var(--focus); }
.send-button { flex: 0 0 auto; min-height: 46px; padding: 10px 17px; }
.send-button svg { width: 19px; height: 19px; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 14px; margin-top: 9px; }
.composer-hint { color: var(--muted); font-size: 10px; line-height: 1.4; }
.send-error { margin: 0 0 12px; padding: 9px 11px; border-radius: 8px; color: var(--error); background: var(--error-bg); font-size: 12px; line-height: 1.5; }
.members-panel { display: flex; flex-direction: column; flex: 0 0 250px; min-width: 0; padding: 26px 20px 20px; border-left: 1px solid var(--line); background: var(--subtle); overflow-y: auto; scrollbar-width: thin; }
.members-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.members-heading h2 { margin: 0; font-size: 18px; letter-spacing: -.35px; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--muted); font-size: 22px; }
#closeMembersButton { display: block; }
.members-status { margin: 10px 0 20px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.members-status.available { color: var(--success); }
.members-list { display: flex; flex-direction: column; gap: 18px; list-style: none; padding: 0; margin: 0; }
.member-row { display: flex; align-items: center; gap: 11px; min-width: 0; }
.member-avatar { position: relative; display: grid; place-items: center; flex: 0 0 auto; width: 35px; height: 35px; border: 1px solid var(--line); border-radius: 11px; background: var(--accent-soft); color: var(--accent-text); font-size: 12px; font-weight: 650; }
.member-avatar::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 6px; height: 6px; border: 2px solid var(--subtle); border-radius: 50%; background: var(--success); box-sizing: content-box; }
.member-detail { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.member-detail strong { color: var(--muted); font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.member-detail small { color: var(--muted); font-size: 10px; }
.members-toggle { display: inline-flex; align-items: center; gap: 7px; }
.count-badge { min-width: 18px; padding: 2px 4px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); font-size: 10px; }
.members-backdrop { display: none; }

/* Owner controls retain the same visual language and scroll independently. */
.control-view { max-width: 1100px; width: 100%; height: 100%; padding: 10px 3px 24px; overflow-y: auto; scrollbar-width: thin; }
.control-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 4px 2px 24px; }
.control-header h1 { margin: 0; font-size: 30px; letter-spacing: -.8px; }
.control-card { padding: 26px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.control-tabs { display: flex; gap: 6px; margin: 0 0 25px; border-bottom: 1px solid var(--line); }
.control-tabs button { padding: 13px 21px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; }
.control-tabs button[aria-pressed="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.stat-card span { display: block; color: var(--muted); font-size: 11px; line-height: 1.5; }
.stat-card strong { display: block; margin-top: 12px; color: var(--ink); font-size: 30px; font-weight: 650; letter-spacing: -1px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.section-heading h2 { margin: 0 0 7px; font-size: 18px; letter-spacing: -.4px; }
.section-heading p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 25px; padding: 21px 0; border-bottom: 1px solid var(--line); }
.setting-row strong, .setting-row label { display: block; color: var(--muted); font-size: 13px; font-weight: 600; }
.setting-row small { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.setting-row input[type="checkbox"] { flex: 0 0 auto; width: 22px; height: 22px; accent-color: var(--accent); cursor: pointer; }
.setting-row select { max-width: 140px; min-height: 40px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); color: var(--muted); font-size: 13px; }
.settings-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 22px; }
.settings-footer p { color: var(--success); font-size: 12px; }
.gate-card { max-width: 510px; margin: 30px auto; padding: 32px; text-align: center; }
.gate-card h2 { margin: 15px 0 12px; font-size: 22px; letter-spacing: -.5px; }
.gate-card > p { margin-bottom: 24px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.gate-card .setup-account { margin: 0 0 20px; color: var(--ink); font-weight: 650; overflow-wrap: anywhere; }
.setup-steps { margin: 0 0 24px; padding: 18px 18px 18px 36px; text-align: left; background: var(--subtle); border: 1px solid var(--line); border-radius: 14px; font-size: 13px; line-height: 1.65; }
.setup-steps li + li { margin-top: 10px; }
.setup-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; margin-bottom: 22px; }
.setup-actions > button { min-height: 42px; }
.gate-card .setup-safety { margin: 22px 0 0; }
.gate-icon { display: grid; place-items: center; width: 48px; height: 48px; margin: auto; border-radius: 14px; background: var(--accent-soft); color: var(--accent-text); font-size: 27px; }
#ownerClaimForm { text-align: left; }
.search-row { display: flex; gap: 10px; margin: 23px 0 18px; }
.search-row input { width: 100%; min-width: 0; min-height: 43px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--field); color: var(--ink); font-size: 14px; }
.management-list { list-style: none; padding: 0; margin: 15px 0 0; }
.management-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 17px 0; border-bottom: 1px solid var(--line); }
.management-row:last-child { border-bottom: 0; }
.management-row .member-detail { flex: 1 1 auto; }
.management-row .row-name { font-size: 13px; overflow-wrap: anywhere; }
.management-row small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.management-row p { margin: 10px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.management-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.danger-button { min-height: 38px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--error-bg); color: var(--error); font-size: 12px; }
.danger-button:hover:not(:disabled) { background: var(--error-bg); }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 22px; }
.pagination span { color: var(--muted); font-size: 12px; }
.moderation-actions { display: flex; align-items: center; gap: 6px; }

@media (max-width: 900px) {
  .members-panel { flex-basis: 220px; padding: 24px 16px 18px; }
  .header-actions { gap: 10px; }
}
@media (max-width: 760px) {
  :root { --bar-height: 64px; }
  .site-bar { padding: 0 18px; gap: 10px; }
  .brand { gap: 8px; font-size: 16px; }
  .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
  .site-actions { gap: 3px; }
  .language-picker { padding: 0 7px; gap: 5px; }
  .language-picker select { max-width: 100px; min-height: 38px; font-size: 12px; }
  .control-link { max-width: 110px; padding: 6px 8px; font-size: 12px; }
  .app { padding: 8px 16px 18px; }
  .join-card { padding: 20px; }
  .join-card h1 { font-size: 22px; }
  .chat-panel { border-radius: 15px; }
  .chat-header { padding: 14px 16px; gap: 10px; }
  .room-icon { display: none; }
  .room-heading h1 { font-size: 19px; }
  .connection-status { font-size: 10px; }
  .members-toggle { display: inline-flex; }
  .members-panel { display: none; position: absolute; z-index: 12; top: 0; right: 0; bottom: 0; width: min(300px, 85%); padding: 25px 23px; border-left: 1px solid var(--line); border-radius: 15px 0 0 15px; box-shadow: -15px 0 60px #1b2c5624; }
  .chat-panel.members-open .members-panel { display: flex; }
  .members-backdrop { position: absolute; z-index: 11; inset: 0; border: 0; background: var(--overlay); }
  #closeMembersButton { display: block; }
  .message-scroll { padding: 20px 17px; }
  .composer { padding: 12px 13px max(12px, env(safe-area-inset-bottom)); }
  .control-header { align-items: flex-start; gap: 12px; }
  .control-header h1 { font-size: 26px; }
  .control-card { padding: 21px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .stat-card { padding: 17px; }
  .section-heading { flex-wrap: wrap; }
  .gate-card { margin-top: 12px; }
}
@media (max-width: 480px) {
  :root { --bar-height: 60px; }
  .site-bar { padding: 0 14px; gap: 8px; }
  .brand { font-size: 15px; gap: 7px; }
  .language-icon { display: none; }
  .app { padding: 4px 8px 10px; }
  .join-view { padding: 8px 0 12px; }
  .join-card { padding: 18px; border-radius: 14px; }
  .join-card h1 { margin-bottom: 16px; font-size: 22px; }
  .chat-header { padding: 12px; }
  .header-actions { gap: 7px; }
  .connection-status { gap: 4px; }
  .connection-status #connectionLabel { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .members-toggle, .leave-button { padding: 6px 9px; font-size: 11px; }
  .chat-panel { border-radius: 13px; }
  .message { max-width: 88%; }
  .message-list { gap: 20px; }
  .message-body { padding: 10px 12px; }
  .composer-row { gap: 8px; }
  .send-button { padding: 10px 14px; }
  .send-button svg { display: none; }
  .composer-footer { margin-top: 7px; }
  #messageInput { max-height: 120px; }
  .control-header { padding-right: 6px; padding-left: 6px; }
  .control-tabs button { padding: 12px 15px; font-size: 12px; }
  .control-card { padding: 18px; }
  .management-row { gap: 12px; }
  .setting-row { gap: 15px; }
  .setting-row select { max-width: 105px; font-size: 12px; }
}
@media (max-width: 380px) {
  .form-grid { grid-template-columns: 1fr; gap: 18px; }
  .site-bar .control-link { max-width: 92px; font-size: 11px; }
}
@media (max-height: 500px) {
  :root { --bar-height: 48px; }
  .brand-mark { width: 30px; height: 30px; }
  .app { padding-top: 0; padding-bottom: 6px; }
  .join-view { padding-top: 6px; padding-bottom: 8px; }
  .chat-header { padding-top: 8px; padding-bottom: 8px; }
  .composer { padding-top: 8px; padding-bottom: max(7px, env(safe-area-inset-bottom)); }
  #messageInput { max-height: 90px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
/* Admin workspace, rank controls and moderation dialogs share the same tokens. */
.theme-icon { color: var(--accent); font-size: 18px; line-height: 1; }
.theme-picker select { max-width: 88px; }
input, textarea, select { accent-color: var(--button); }
select option { color: var(--ink); background: var(--surface); }
.restriction-notice { flex: 0 0 auto; padding: 11px 24px; color: var(--warning); background: var(--warning-bg); border-bottom: 1px solid var(--line); font-size: 13px; line-height: 1.5; }
.message-name:is(button), .member-name-button { padding: 0; min-width: 0; border: 0; background: transparent; color: var(--accent); text-align: start; font-size: inherit; font-weight: 650; overflow-wrap: anywhere; }
.message-name:is(button) { font-size: 11px; }
.member-name-button { font-size: 13px; }
.member-name-button:hover, .message-name:is(button):hover { text-decoration: underline; }
.rank-badge { display: inline-flex; align-items: center; align-self: flex-start; max-width: 100%; padding: 3px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-text); font-size: 10px; font-weight: 650; line-height: 1.4; white-space: nowrap; }
.rank-badge[data-rank="guest"] { color: var(--muted); background: var(--subtle); }
.rank-badge[data-rank="vip"], .rank-badge[data-rank="vip_plus"] { color: #6c3c99; background: #f1e8fc; }
.rank-badge[data-rank="superadmin"] { color: #71510a; background: #fff1c6; }
.rank-badge[data-rank="webmaster"] { color: #543392; background: #eee4ff; }
:root:is([data-theme="dark"], [data-theme="dark_blue"]) .rank-badge[data-rank="vip"], :root:is([data-theme="dark"], [data-theme="dark_blue"]) .rank-badge[data-rank="vip_plus"] { color: #dfbfff; background: #382c4d; }
:root:is([data-theme="dark"], [data-theme="dark_blue"]) .rank-badge[data-rank="superadmin"] { color: #f4d58c; background: #423820; }
:root:is([data-theme="dark"], [data-theme="dark_blue"]) .rank-badge[data-rank="webmaster"] { color: #d8c2ff; background: #362c50; }
.control-view { max-width: 1240px; padding: 6px 1px 18px; }
.control-header { padding: 4px 2px 22px; }
.control-header h1 { font-size: 28px; }
.control-header-actions { display: flex; align-items: center; gap: 10px; }
.control-header-actions > .rank-badge { align-self: center; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.control-menu { display: none; }
.control-workspace { display: grid; grid-template-columns: 184px minmax(0, 1fr); gap: 22px; align-items: start; }
.control-main { min-width: 0; }
.control-tabs { position: sticky; top: 0; display: flex; flex-direction: column; gap: 5px; margin: 0; padding: 10px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.control-tabs button { min-height: 44px; padding: 12px 13px; border: 0; border-radius: 9px; color: var(--muted); text-align: start; font-size: 13px; line-height: 1.4; }
.control-tabs button:hover:not(:disabled) { background: var(--subtle); color: var(--ink); }
.control-tabs button[aria-pressed="true"] { color: var(--accent-text); background: var(--accent-soft); }
.control-section > .section-heading { margin-bottom: 18px; }
.control-card { border-radius: 15px; padding: 23px; }
.control-section h2, .control-card h3 { margin: 0; font-size: 20px; letter-spacing: -.4px; }
.control-card h3 { font-size: 17px; }
.stat-grid { gap: 12px; margin: 0 0 20px; }
.stat-card { padding: 19px; border-radius: 13px; }
.stat-card span { color: var(--muted); font-size: 12px; }
.stat-card strong { color: var(--ink); margin-top: 13px; font-size: 30px; }
.overview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.overview-grid .control-card { min-width: 0; }
.overview-grid .section-heading { align-items: center; }
.overview-grid .management-row { align-items: flex-start; padding: 14px 0; }
.overview-grid .management-row p { margin: 4px 0 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.overview-grid .management-row small { font-size: 10px; }
.overview-grid .member-detail strong { color: var(--ink); font-size: 13px; }
.overview-member { justify-content: flex-start; }
.overview-settings { margin-top: 18px; }
.overview-settings-items { display: flex; gap: 20px; flex-wrap: wrap; align-items: center; margin-top: 20px; }
.overview-settings-items > div { min-width: 85px; flex: 1 1 auto; }
.overview-settings-items span { display: block; color: var(--muted); font-size: 11px; }
.overview-settings-items strong { display: block; margin-top: 7px; color: var(--ink); font-size: 13px; }
.management-actions { flex-wrap: wrap; justify-content: flex-end; max-width: 62%; }
.management-actions button { white-space: nowrap; }
.management-row .rank-badge { display: inline-flex; }
.rank-select, .setting-row input[type="number"] { min-height: 40px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--field); font-size: 13px; }
.setting-row input[type="number"] { max-width: 100px; }
.rank-table-scroll { overflow-x: auto; margin-top: 22px; border: 1px solid var(--line); border-radius: 12px; }
.rank-table { border-collapse: collapse; min-width: 520px; width: 100%; font-size: 13px; }
.rank-table th, .rank-table td { text-align: center; padding: 15px 12px; border-bottom: 1px solid var(--line); }
.rank-table th:first-child, .rank-table td:first-child { text-align: start; }
.rank-table thead { background: var(--subtle); color: var(--ink); }
.rank-table tbody tr:last-child > * { border-bottom: 0; }
.rank-table .rank-badge { font-size: 12px; padding: 4px 9px; }
.permission-yes { color: var(--success); font-size: 20px; font-weight: 700; }
.permission-no { color: var(--muted); }
.history-card { margin-top: 20px; }
.action-dialog { width: min(480px, calc(100vw - 24px)); max-height: calc(var(--app-height) - 24px); padding: 18px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: var(--surface); box-shadow: 0 20px 80px #0003; overflow-y: auto; }
.action-dialog::backdrop { background: var(--overlay); }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-heading .icon-button { flex: 0 0 44px; width: 44px; height: 44px; }
.dialog-heading h2 { margin: 0; min-width: 0; font-size: 18px; font-weight: 600; line-height: 1.3; letter-spacing: -.25px; overflow-wrap: anywhere; }
.dialog-target { margin: 12px 0 22px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.action-preview { padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--subtle); line-height: 1.6; }
.action-preview strong { display: block; font-size: 15px; }
.action-preview p { margin: 8px 0 0; color: var(--muted); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 7px; }
@media (max-width: 1000px) {
  .control-workspace { grid-template-columns: 160px minmax(0, 1fr); gap: 16px; }
  .control-tabs { padding: 8px; }
  .control-tabs button { padding: 11px 10px; font-size: 12px; }
  .overview-grid { gap: 12px; }
  .overview-grid .control-card { padding: 18px; }
  .stat-card { padding: 15px; }
  .account-row { align-items: flex-start; flex-direction: column; }
  .management-actions { max-width: 100%; justify-content: flex-start; }
}
@media (max-width: 760px) {
  .control-workspace { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .control-tabs { display: none; position: static; }
  .control-workspace.menu-open .control-tabs { display: flex; }
  .control-menu { display: inline-block; }
  .control-header { padding-bottom: 16px; gap: 10px; }
  .control-header h1 { font-size: 23px; }
  .control-header-actions { flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
  .control-header-actions > .rank-badge { max-width: 180px; }
  .overview-grid { grid-template-columns: minmax(0, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .control-card { padding: 20px; }
  .restriction-notice { padding: 10px 16px; font-size: 12px; }
}
@media (max-width: 600px) {
  .site-bar { gap: 8px; padding-inline: 12px; }
  .site-bar .brand > span:last-child { display: none; }
  .site-bar .brand-mark { width: 32px; height: 32px; }
  .site-actions { min-width: 0; flex: 1; gap: 6px; justify-content: flex-end; }
  .site-actions .language-picker { padding: 0 6px; gap: 4px; }
  .site-actions .language-picker select { max-width: 85px; font-size: 12px; min-height: 38px; }
  .site-actions .theme-picker select { max-width: 68px; }
  .site-actions .language-icon, .site-actions .theme-icon { display: none; }
  .site-bar .control-link { max-width: 84px; min-height: 38px; padding: 5px; font-size: 11px; }
}
@media (max-width: 480px) {
  .control-header { align-items: center; }
  .control-header-actions > .rank-badge { display: none; }
  .control-header h1 { font-size: 21px; }
  .control-header-actions .leave-button { min-height: 38px; }
  .control-card { padding: 17px; }
  .stat-card { padding: 16px; }
  .stat-card span { font-size: 11px; }
  .stat-card strong { font-size: 27px; }
  .management-row { align-items: flex-start; }
  .management-actions { gap: 7px; }
  .overview-settings-items { gap: 18px; }
  .action-dialog { padding: 16px; }
  .rank-table-scroll { margin-top: 17px; }
}
.control-header > div:first-child { min-width: 0; }
.control-header h1 { overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .control-header-actions { flex: 0 0 auto; max-width: 62%; }
}

/* Members directory: one semantic table, stacked as labeled cards on small screens. */
.members-directory { min-width: 0; }
.member-search { margin-top: 22px; }
.member-search .search-row { margin: 0 0 15px; }
.member-filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.member-filters label { display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 600; }
.member-filters select, .member-rank-form select { width: 100%; min-width: 0; min-height: 42px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--field); color: var(--ink); font: inherit; font-size: 12px; }
.member-table-scroll { width: 100%; margin-top: 15px; overflow-x: auto; }
.member-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 12px; }
.member-table th { padding: 12px 10px; border-block: 1px solid var(--line); background: var(--subtle); color: var(--muted); font-size: 10px; font-weight: 600; white-space: nowrap; }
.member-table td { padding: 17px 10px; border-bottom: 1px solid var(--line); color: var(--muted); line-height: 1.6; vertical-align: middle; }
.member-table th:first-child, .member-table td:first-child { padding-left: 12px; }
.member-table th:last-child, .member-table td:last-child { padding-right: 12px; }
.member-table .directory-row:last-child td { border-bottom: 0; }
.directory-row:hover { background: var(--subtle); }
.directory-identity { display: flex; align-items: flex-start; gap: 11px; min-width: 155px; }
.directory-identity .member-avatar { flex: 0 0 35px; width: 35px; height: 35px; font-size: 13px; }
.directory-name { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.member-name-button { max-width: 200px; padding: 0; border: 0; background: none; color: var(--ink); font-size: 12px; font-weight: 650; line-height: 1.5; text-align: left; overflow-wrap: anywhere; }
.member-name-button:hover { color: var(--accent-text); text-decoration: underline; }
.directory-email { display: block; max-width: 200px; color: var(--muted); font-size: 10px; line-height: 1.6; overflow-wrap: anywhere; }
.member-presence { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.member-presence::before { content: ""; width: 5px; height: 5px; flex: 0 0 5px; border-radius: 50%; background: var(--muted); }
.member-presence[data-online="true"]::before { background: var(--success); }
.member-access { display: inline-flex; align-items: center; padding: 4px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--subtle); color: var(--muted); font-size: 10px; font-weight: 600; white-space: nowrap; }
.member-access[data-access="active"] { color: var(--success); }
.member-access[data-access="banned"], .member-access[data-access="suspended"] { background: var(--error-bg); color: var(--error); }
.member-access[data-access="muted"], .member-access[data-access="kicked"] { background: var(--accent-soft); color: var(--accent-text); }
.directory-open .leave-button { min-height: 36px; white-space: nowrap; }
.member-detail-navigation { align-items: center; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.member-profile-hero { display: flex; gap: 17px; align-items: center; padding: 19px 0 26px; }
.member-profile-avatar { display: grid; place-items: center; flex: 0 0 60px; width: 60px; height: 60px; border: 1px solid var(--line); border-radius: 19px; background: var(--accent-soft); color: var(--accent-text); font-size: 24px; font-weight: 650; }
.member-profile-heading { min-width: 0; }
.member-profile-heading h3 { margin: 0 0 9px; color: var(--ink); font-size: 23px; letter-spacing: -.5px; overflow-wrap: anywhere; }
.member-profile-badges { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.member-profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 16px; }
.member-info-card { min-width: 0; padding: 19px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.member-info-card > h3 { margin: 0 0 17px; font-size: 14px; letter-spacing: -.2px; }
.member-facts { display: flex; flex-direction: column; gap: 14px; margin: 0; }
.member-fact { display: grid; grid-template-columns: minmax(75px, .8fr) minmax(0, 1.3fr); gap: 16px; align-items: start; }
.member-fact dt { color: var(--muted); font-size: 11px; line-height: 1.6; }
.member-fact dd { margin: 0; color: var(--ink); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.member-capabilities { display: flex; flex-direction: column; gap: 8px; margin: 18px 0 0; padding: 16px 0 0 17px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.6; }
.member-info-card > .field-hint { margin: 16px 0 0; line-height: 1.7; }
.member-wide-card, .member-actions-card { grid-column: 1 / -1; }
.member-wide-card .management-list { margin-top: 0; }
.member-wide-card .management-row:first-child { padding-top: 0; }
.member-wide-card .management-row:last-child { padding-bottom: 0; }
.member-action-buttons { display: flex; flex-wrap: wrap; gap: 9px; }
.member-rank-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 17px; }
.member-rank-form label { color: var(--muted); font-size: 12px; }
.member-rank-form select { width: auto; min-width: 130px; }
.member-info-card .member-detail { min-width: 0; }
.member-info-card .management-row { align-items: flex-start; }
@media (min-width: 1101px) {
  .member-table { min-width: 740px; }
}
@media (max-width: 1100px) {
  .member-table-scroll { overflow: visible; }
  .member-table, .member-table tbody { display: block; width: 100%; }
  .member-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .member-table .directory-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 16px; margin-bottom: 14px; padding: 17px; border: 1px solid var(--line); border-radius: 12px; }
  .member-table .directory-row td { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; gap: 5px; padding: 0; border: 0; overflow-wrap: anywhere; }
  .member-table .directory-row td::before { content: attr(data-label); color: var(--muted); font-size: 10px; }
  .member-table .directory-row .directory-member { grid-column: 1 / -1; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
  .member-table .directory-row .directory-member::before, .member-table .directory-row .directory-open::before { display: none; }
  .member-table .directory-row .directory-open { align-self: end; align-items: flex-end; }
  .member-table .directory-open .leave-button { min-width: 82px; }
  .member-name-button, .directory-email { max-width: none; }
  .directory-identity { min-width: 0; width: 100%; }
}
@media (max-width: 600px) {
  .member-profile-grid { grid-template-columns: minmax(0, 1fr); gap: 13px; }
  .member-filters { gap: 8px; }
  .member-filters select { padding-inline: 7px; font-size: 11px; }
  .member-profile-hero { gap: 13px; }
  .member-profile-heading h3 { font-size: 20px; }
  .member-profile-avatar { flex-basis: 50px; width: 50px; height: 50px; border-radius: 15px; font-size: 21px; }
  .member-info-card { padding: 16px; }
  .member-rank-form label { flex: 1 0 100%; }
  .member-rank-form select { flex: 1 1 auto; }
}


/* Rooms, social actions and a visible composer picker use the existing theme tokens. */
.smileys-button { display:grid; place-items:center; flex:0 0 46px; width:46px; min-height:46px; padding:0; border:1px solid var(--line); border-radius:12px; color:var(--accent); background:var(--accent-soft); font-size:29px; line-height:1; }
.smileys-button:hover { border-color:var(--accent); }
.sticker-draft { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:9px; padding:10px 12px; background:var(--accent-soft); border-radius:12px; color:var(--accent-text); }
.sticker-draft > span { font-size:19px; }
.message-body.sticker-message { font-size:42px; line-height:1.35; padding:10px 18px; }
.message-body.sticker-message small { display:block; font-size:12px; line-height:1.4; text-align:center; margin-top:3px; }
.message-name:is(button), .member-name-button { border-radius:4px; }
.message-name:is(button):hover, .member-name-button:hover { background:var(--accent-soft); }
.community-dialog { width:min(600px,calc(100vw - 24px)); }
#communityDialogContent { margin-top:12px; }
#communityDialogStatus:empty { display:none; }
.community-dialog .pagination { margin-top:12px; gap:10px; }
.community-dialog .field-hint { margin-bottom:8px; }
.community-dialog > .dialog-heading h2 { overflow-wrap:anywhere; min-width:0; }
.community-menu { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.community-menu button { min-height:44px; padding:12px; text-align:start; }
.community-profile-heading { display:flex; align-items:center; gap:12px; margin:14px 0 20px; }
.community-profile-heading h3 { margin:0; overflow-wrap:anywhere; }
.community-profile-heading p { margin:5px 0 0; color:var(--muted); font-size:12px; }
.community-list { display:grid; gap:8px; list-style:none; margin:0; padding:0; }
.community-list-row, .room-card { display:flex; justify-content:space-between; align-items:center; gap:10px; padding:10px 12px; border:1px solid var(--line); border-radius:10px; background:var(--surface); font-size:14px; }
.community-list-row > div, .room-card > div { min-width:0; }
.community-list-row strong, .room-card strong { display:block; font-size:14px; font-weight:600; overflow-wrap:anywhere; }
.community-list-row small, .room-card small { display:block; color:var(--muted); font-size:12px; line-height:1.45; margin-top:4px; overflow-wrap:anywhere; }
.community-list-row > button, .room-card > button { flex:0 0 auto; }
.room-cards { display:grid; gap:10px; }
.room-admin-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }
.room-admin-card { padding:18px; border:1px solid var(--line); border-radius:14px; min-width:0; }
.room-admin-card h3 { margin:0; overflow-wrap:anywhere; }
.room-admin-card p { color:var(--muted); font-size:12px; line-height:1.7; overflow-wrap:anywhere; }
.room-admin-meta { display:flex; flex-wrap:wrap; gap:7px; margin:12px 0; }
.room-admin-members { padding:0; margin:10px 0 16px; list-style:none; display:grid; gap:7px; }
.room-admin-members li { display:flex; justify-content:space-between; gap:8px; color:var(--muted); font-size:12px; overflow-wrap:anywhere; }
.room-editor { display:grid; gap:16px; margin-top:22px; padding-top:22px; border-top:1px solid var(--line); }
.room-editor h3 { margin:0; }
.room-editor .form-field { display:grid; gap:7px; }
.room-editor textarea, .community-report-form textarea { width:100%; min-height:90px; padding:12px; color:var(--ink); background:var(--field); border:1px solid var(--line); border-radius:10px; resize:vertical; font:inherit; }
.room-enabled-label { display:flex; gap:9px; align-items:center; }
.room-enabled-label input { width:auto; }
.section-buttons { display:flex; gap:10px; flex-wrap:wrap; }
.section-buttons .primary-button { padding:11px 15px; font-size:12px; }
.report-filter-label { display:flex; gap:12px; align-items:center; margin-bottom:12px; }
.report-filter-label select { max-width:230px; }
.community-report-form { display:grid; gap:12px; }
.community-report-form label { display:grid; gap:7px; }
.picker-tabs { display:flex; gap:8px; margin:20px 0 14px; }
.picker-tabs [aria-pressed="true"] { color:var(--accent-text); border-color:var(--accent); background:var(--accent-soft); }
.picker-items { display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); gap:8px; }
.picker-item { min-width:0; min-height:48px; padding:8px; border:1px solid var(--line); border-radius:12px; color:var(--ink); background:var(--surface); font-size:28px; }
.picker-item:hover { background:var(--accent-soft); border-color:var(--accent); }
.picker-items.sticker-picker { grid-template-columns:repeat(3,minmax(0,1fr)); }
.picker-items.sticker-picker .picker-item { min-height:93px; font-size:36px; }
.picker-item small { display:block; font-size:11px; margin-top:6px; }
.private-chat-list { display:flex; flex-direction:column; gap:12px; height:clamp(220px,42vh,420px); overflow-y:auto; margin:14px 0; padding:10px 4px; list-style:none; }
.private-chat-list li { align-self:flex-start; max-width:85%; padding:10px 13px; border-radius:13px; background:var(--subtle); border:1px solid var(--line); }
.private-chat-list li.own { align-self:flex-end; color:var(--accent-text); background:var(--accent-soft); }
.private-chat-list p { margin:0; white-space:pre-wrap; overflow-wrap:anywhere; font-size:14px; }
.private-chat-list time { display:block; margin-top:5px; color:var(--muted); font-size:10px; }
.private-composer { display:flex; align-items:flex-end; gap:9px; }
.private-composer textarea { flex:1; width:100%; min-width:0; min-height:46px; max-height:120px; padding:12px; resize:vertical; border:1px solid var(--line); border-radius:12px; color:var(--ink); background:var(--field); font:inherit; }
.private-composer .primary-button { padding:13px 17px; min-height:46px; }
.private-chat-notice { font-size:12px; color:var(--muted); }
@media(max-width:700px) { .room-admin-grid { grid-template-columns:1fr; } .community-menu { grid-template-columns:1fr; } }
@media(max-width:390px) { .picker-items { grid-template-columns:repeat(5,minmax(0,1fr)); } }

.community-row { display:flex; justify-content:space-between; align-items:center; gap:10px; padding:10px 12px; border:1px solid var(--line); border-radius:10px; background:var(--surface); color:var(--ink); text-align:start; width:100%; min-width:0; font-size:14px; }
.community-row > span { min-width:0; }.community-row strong { display:block; font-weight:600; overflow-wrap:anywhere; }.community-row small { display:block; margin-top:4px; color:var(--muted); font-size:12px; line-height:1.45; overflow-wrap:anywhere; }
.private-conversation:hover { border-color:var(--accent); background:var(--subtle); }
.private-composer { display:block; }.private-composer .composer-row { width:100%; }.private-composer .send-button { flex:0 0 auto; }
.private-chat-list .message-meta { margin-bottom:5px; font-size:10px; }.private-chat-list .message-body { border:0; background:transparent; padding:0; }.private-chat-list .sticker-message { font-size:42px; }
.room-rank-counts { display:flex; gap:6px; flex-wrap:wrap; margin:12px 0 17px; }.room-admin-meta { font-size:12px; color:var(--muted); }.room-admin-meta > span { flex-basis:100%; }
.room-editor .member-filters { flex-wrap:wrap; }.room-editor .member-filters > label { flex:1 1 180px; }.room-editor input:not([type="checkbox"]) { width:100%; min-height:43px; padding:10px 13px; border:1px solid var(--line); border-radius:9px; background:var(--field); color:var(--ink); font:inherit; }
.report-filter-label select { min-height:40px; padding:8px 12px; border:1px solid var(--line); border-radius:8px; background:var(--field); color:var(--ink); }
.report-row { align-items:flex-start; flex-wrap:wrap; }.report-row .management-info { flex:1 1 300px; min-width:0; }.report-row .management-actions { flex-wrap:wrap; }.report-reason { white-space:pre-wrap; overflow-wrap:anywhere; }
.community-dialog .member-facts { display:grid; grid-template-columns:auto 1fr; gap:12px; }.community-dialog .member-facts dd { margin:0; overflow-wrap:anywhere; }

/* Communication controls stay close to the composer without narrowing phone input. */
.composer-tools { display:flex; align-items:center; gap:8px; flex:0 0 auto; }
.communication-button { position:relative; display:grid; place-items:center; flex:0 0 44px; width:44px; min-width:44px; min-height:46px; padding:10px; border:1px solid var(--line); border-radius:12px; background:var(--accent-soft); color:var(--accent-text); }
.communication-button svg { width:24px; height:24px; pointer-events:none; }
.communication-button:hover:not(:disabled) { border-color:var(--accent); background:var(--subtle); }
.communication-badge { position:absolute; top:-5px; right:-5px; min-width:19px; height:19px; padding:0 5px; display:grid; place-items:center; border:2px solid var(--surface); border-radius:12px; background:var(--accent); color:#fff; font-size:10px; font-weight:750; line-height:1; }
.friends-tabs { display:flex; gap:8px; margin:0 0 10px; }.friends-tabs button { flex:1; min-width:0; min-height:40px; overflow-wrap:anywhere; }
.friends-tabs [aria-pressed="true"] { background:var(--accent-soft); border-color:var(--accent); color:var(--accent-text); }
.friend-notification[data-unread="true"] { border-color:var(--accent); background:var(--subtle); }
.friend-notification .notification-status { color:var(--accent-text); font-weight:650; }
.presence-away { display:inline-block; color:var(--muted); font-size:10px; margin-left:6px; }

/* Compact Lobby layout; preserve the approved feature order in every theme. */
:root {
  --chat-chrome: var(--surface); --chat-composer: var(--chat-chrome); --chat-sidebar: var(--subtle);
  --chat-incoming: var(--subtle); --chat-outgoing: var(--accent-soft);
  --chat-avatar: var(--accent-soft); --chat-avatar-ink: var(--accent-text);
  --bar-height: 54px;
}
:root[data-theme="blue"] {
  --chat-chrome: #f6faff; --chat-sidebar: #eaf3ff;
  --chat-incoming: #e7effb; --chat-outgoing: #d3e4ff;
  --chat-avatar: #cfe1ff; --chat-avatar-ink: #143779;
}
/* Sky and cyan accents with a deep-ocean composer, at the same density. */
:root[data-theme="dark_blue"] {
  --chat-chrome: #0b3853; --chat-composer: #075985; --chat-sidebar: #0b3853;
  --chat-incoming: #10455f; --chat-outgoing: #155675;
  --chat-avatar: #0e7490; --chat-avatar-ink: #f0f9ff;
}
:root[data-theme="dark_blue"] .brand-mark { color: #06b6d4; }
.site-bar { max-width: 1632px; padding: 0 20px; gap: 16px; }
.site-bar .brand { font-size: 20px; font-weight: 600; gap: 8px; letter-spacing: -.4px; }
.site-bar .brand-mark { width: 30px; height: 32px; background: transparent; border-radius: 0; }
.site-bar .brand-mark svg { width: 28px; height: 28px; }
.site-actions { flex: 0 1 auto; min-width: 0; gap: 8px; }
.site-actions .language-picker { min-width: 0; gap: 6px; padding: 0 8px; border-radius: 8px; }
.site-actions .language-picker select { min-width: 0; min-height: 36px; color: var(--ink); font-size: 13px; }
.site-actions .language-icon { width: 16px; height: 16px; }
.site-actions .theme-icon { font-size: 18px; }
.site-bar .control-link { min-width: 0; max-width: 210px; min-height: 36px; padding: 7px 12px; border: 1px solid var(--button); border-radius: 8px; color: var(--on-accent); background: var(--button); font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.site-bar .control-link:hover:not(:disabled) { background: var(--button-hover); border-color: var(--button-hover); }
.app { padding: 0 12px 12px; }
.chat-panel { max-width: 1600px; border-radius: 14px; box-shadow: none; }
.chat-header { min-height: 52px; padding: 6px 18px; gap: 16px; flex-wrap: wrap; background: var(--chat-chrome); }
.room-heading { flex: 1 1 220px; gap: 16px; }
.room-title-group { min-width: 0; }
.room-heading h1 { font-size: 20px; font-weight: 600; line-height: 1.2; letter-spacing: -.35px; overflow-wrap: anywhere; }
.room-navigation { flex: 0 0 auto; }
.rooms-button { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 5px 10px; color: var(--ink); font-size: 13px; border-radius: 8px; white-space: nowrap; }
.rooms-button > svg { width: 16px; height: 16px; }
.rooms-button .room-chevron { margin-left: 1px; width: 15px; height: 15px; }
.rooms-button .count-badge { display: inline-grid; place-items: center; min-width: 21px; min-height: 20px; padding: 1px 5px; font-size: 12px; border-radius: 5px; }
.header-actions { flex: 0 1 auto; min-width: 0; margin-left: auto; gap: 14px; }
.chat-header .leave-button { min-height: 36px; border-radius: 8px; }
.header-actions .leave-button { flex: 0 0 auto; padding: 6px 10px; color: var(--ink); font-size: 12px; }
.connection-status { min-width: 0; gap: 6px; color: var(--ink); font-size: 12px; line-height: 1.35; white-space: normal; }
.connection-status #connectionLabel { overflow-wrap: anywhere; }
.status-dot { flex: 0 0 6px; width: 6px; height: 6px; }

/* Members keep one row per identity, including actual role/gift/device data. */
.members-panel { flex-basis: 260px; padding: 16px 16px 12px; background: var(--chat-sidebar); overflow: hidden; }
.members-heading, .members-status, .members-footer { flex: 0 0 auto; }
.members-heading h2 { font-size: 18px; font-weight: 600; line-height: 1.3; letter-spacing: -.25px; }
.members-heading-label { display: flex; align-items: center; gap: 8px; min-width: 0; }
.members-count-pill { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 40px; min-height: 23px; padding: 2px 8px; border-radius: 14px; background: var(--accent-soft); color: var(--muted); font-size: 12px; font-weight: 500; }
.members-count-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.members-count-pill.available { color: var(--success); background: color-mix(in srgb, var(--success) 12%, var(--surface)); }
.members-panel .members-heading { margin-bottom: 10px; }
.members-status { margin: 6px 0 12px; font-size: 12px; }
.members-panel .members-list { flex: 1 1 auto; min-height: 0; gap: 0; padding: 0 3px 8px; margin: 0 -3px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.members-panel .member-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 20px 18px auto; align-items: center; gap: 6px; min-height: 44px; padding: 0; border-bottom: 1px solid var(--line); }
.members-panel .member-avatar { grid-column: 1; width: 28px; height: 28px; border: 0; border-radius: 50%; background: var(--chat-avatar); color: var(--chat-avatar-ink); font-size: 12px; }
.members-panel .member-avatar::after { width: 6px; height: 6px; right: -1px; bottom: -1px; border: 1.5px solid var(--chat-sidebar); }
.members-panel .member-row[data-presence="away"] .member-avatar::after { background: var(--warning); }
.member-avatar img, .message-avatar img, .member-profile-avatar img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.members-panel .member-detail { grid-column: 2; display: block; min-width: 0; padding: 0; }
.members-panel .member-name-button, .members-panel .member-detail strong { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-size: 13px; font-weight: 500; line-height: 1.5; }
.members-panel .member-name-button { width: 100%; min-height: 44px; }
.members-panel .member-detail small { margin: 0; font-size: 11px; }
.member-rank-icon { --rank-color: var(--accent-text); --rank-tint: var(--accent-soft); position: relative; grid-column: 3; display: grid; place-items: center; width: 20px; height: 24px; color: var(--rank-color); }
.rank-symbol { position: relative; isolation: isolate; display: grid; place-items: center; width: 20px; height: 23px; padding-bottom: 2px; clip-path: polygon(50% 0,98% 18%,93% 66%,77% 84%,50% 100%,23% 84%,7% 66%,2% 18%); background: var(--rank-color); font-size: 12px; line-height: 1; font-weight: 600; }
.rank-symbol::before { content: ""; position: absolute; inset: 1px; z-index: -1; clip-path: inherit; border-radius: inherit; background: var(--rank-tint); }
.rank-decoration { position: absolute; top: -4px; right: -3px; font-size: 11px; line-height: 1; text-shadow: 0 1px var(--surface); }
.member-rank-icon[data-rank="webmaster"] { --rank-color: #613396; --rank-tint: #eadbff; }
.member-rank-icon[data-rank="webmaster"] .rank-decoration { top: -5px; right: 4px; font-size: 12px; }
.member-rank-icon[data-rank="moderator"] { --rank-color: #096773; --rank-tint: #bceef0; }
.member-rank-icon[data-rank="superadmin"], .member-rank-icon[data-rank="vip"], .member-rank-icon[data-rank="vip_plus"] { --rank-color: #865510; --rank-tint: #ffedbc; }
.member-rank-icon[data-rank="vip"] .rank-symbol, .member-rank-icon[data-rank="vip_plus"] .rank-symbol { width: 21px; height: 21px; clip-path: polygon(50% 0,100% 50%,50% 100%,0 50%); padding: 0; font-size: 8px; }
.member-rank-icon[data-rank="guest"] .rank-symbol, .member-rank-icon[data-rank="register"] .rank-symbol { width: 20px; height: 20px; clip-path: none; border-radius: 50%; padding: 0; font-size: 11px; color: var(--muted); background: var(--subtle); }
.member-rank-icon[data-rank="guest"] .rank-symbol::before, .member-rank-icon[data-rank="register"] .rank-symbol::before { display: none; }
:root:is([data-theme="dark"], [data-theme="dark_blue"]) .member-rank-icon[data-rank="webmaster"] { --rank-color: #d8c2ff; --rank-tint: #362c50; }
:root:is([data-theme="dark"], [data-theme="dark_blue"]) .member-rank-icon[data-rank="moderator"] { --rank-color: #90e1e8; --rank-tint: #153e49; }
:root:is([data-theme="dark"], [data-theme="dark_blue"]) .member-rank-icon[data-rank="superadmin"], :root:is([data-theme="dark"], [data-theme="dark_blue"]) .member-rank-icon[data-rank="vip"], :root:is([data-theme="dark"], [data-theme="dark_blue"]) .member-rank-icon[data-rank="vip_plus"] { --rank-color: #f4d58c; --rank-tint: #423820; }
.member-gift { grid-column: 4; font-size: 16px; line-height: 1; }
.member-devices { grid-column: 5; display: flex; gap: 3px; align-items: center; justify-content: flex-end; color: var(--ink); }
.member-devices svg { width: 16px; height: 16px; }
.members-footer { margin-top: auto; padding-top: 8px; border-top: 1px solid var(--line); }
.ignored-button { display: inline-flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 8px 4px; color: var(--accent-text); font-size: 13px; font-weight: 400; text-align: start; }
.ignored-button svg { width: 20px; height: 20px; }

.message-scroll { padding: 18px; }
.message-list { gap: 18px; }
.message { display: grid; grid-template-columns: 30px minmax(0, 1fr); column-gap: 10px; row-gap: 5px; max-width: 91%; align-items: start; justify-items: start; }
.message.own { grid-template-columns: minmax(0, 1fr) 30px; align-items: start; }
.message > .message-meta { grid-column: 2; grid-row: 1; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 1px; min-width: 0; line-height: 1.4; }
.message.own > .message-meta { grid-column: 1; flex-direction: row; justify-content: flex-end; justify-self: end; }
.message .message-name { color: var(--ink); font-size: 13px; font-weight: 500; line-height: 1.4; }
.message .message-time { font-size: 12px; }
.message .rank-badge { font-size: 10px; font-weight: 500; padding: 2px 6px; }
.message > .message-body { grid-column: 2; grid-row: 2; border: 0; border-radius: 11px; padding: 9px 12px; background: var(--chat-incoming); font-size: 15px; line-height: 1.5; }
.message.own > .message-body { grid-column: 1; justify-self: end; color: var(--ink); background: var(--chat-outgoing); border-radius: 11px; }
.message-avatar { grid-column: 1; grid-row: 1 / 3; display: grid; place-items: center; width: 30px; height: 30px; margin-top: 2px; border-radius: 9px; background: var(--chat-avatar); color: var(--chat-avatar-ink); font-size: 13px; font-weight: 600; line-height: 1; user-select: none; }
.message.own > .message-avatar { grid-column: 2; }
.message > .message-body.sticker-message { font-size: 42px; line-height: 1.35; padding: 10px 18px; }

/* The composer retains smileys / input / upload / send, then friends / private. */
#messageForm { padding: 8px 16px 7px; background: var(--chat-composer); }
#messageForm > .composer-row { display: flex; flex-wrap: nowrap; align-items: flex-end; gap: 8px; }
#messageForm .composer-tools { flex: 0 0 auto; gap: 0; }
#messageForm .composer-tools > button, #messageForm .upload-button { width: 44px; min-width: 44px; height: 44px; min-height: 44px; flex: 0 0 44px; padding: 9px; border-radius: 9px; }
#messageForm .composer-tools > button { background: var(--surface); color: var(--accent); }
#messageForm .composer-tools > button:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }
#messageForm .composer-tools svg, #messageForm .upload-button svg { width: 22px; height: 22px; }
#messageForm .communication-badge { top: -4px; right: -4px; min-width: 18px; height: 18px; font-size: 10px; font-weight: 600; border-color: var(--chat-composer); background: var(--button); color: var(--on-accent); }
#messageForm #messageInput { flex: 1 1 auto; width: 100%; min-width: 0; min-height: 44px; padding: 10px 12px; border-radius: 9px; background: var(--surface); font-size: 15px; line-height: 22px; }
#messageInput::placeholder { font-size: inherit; }
#messageForm #sendButton { min-height: 44px; padding: 10px 14px; gap: 7px; border-radius: 9px; font-size: 14px; font-weight: 600; }
#messageForm .send-button svg { display: block; width: 19px; height: 19px; }
#messageForm .composer-footer { align-items: center; margin-top: 6px; min-height: 44px; }
.composer-social-tools { display: flex; align-items: center; gap: 10px; }
.composer-social-tools > button { flex: 0 0 44px; width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 9px; background: var(--surface); border-radius: 9px; }
.composer-social-tools > button svg { width: 22px; height: 22px; }
#messageForm .counter { font-size: 12px; line-height: 1.4; white-space: nowrap; }
.attachment-draft { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--subtle); font-size: 12px; }
.attachment-draft > span { min-width: 0; overflow-wrap: anywhere; }
.attachment-draft button { flex: 0 0 auto; font-size: 12px; }

/* One frame follows the media's intrinsic width instead of filling its grid track. */
.message-body.attachment-message { width: fit-content; max-width: min(100%, 332px); }
.message > .message-body.attachment-message { padding: 5px; border: 1px solid var(--line); border-radius: 10px; }
.attachment-card { display: flex; align-items: center; gap: 8px; width: fit-content; max-width: 100%; padding: 4px 6px; border: 0; border-radius: 6px; color: var(--accent-text); background: transparent; text-decoration: none; }
.attachment-card:hover { background: var(--surface); }
.attachment-card span { min-width: 0; overflow-wrap: anywhere; }
.attachment-card small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.attachment-card.attachment-image { padding: 0; }
.message-attachment { display: block; width: fit-content; max-width: 100%; margin-top: 8px; }
.attachment-only .message-attachment { margin-top: 0; }
.message-attachment img { display: block; width: auto; height: auto; max-width: min(100%, 320px); max-height: 280px; border-radius: 6px; object-fit: contain; }
.private-chat-list li.attachment-message-row { padding: 6px; }
.avatar-editor, .member-media-settings { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.avatar-editor input[type="file"] { max-width: 100%; font-size: 12px; }
.member-media-settings input[type="number"] { width: 130px; min-height: 42px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--field); color: var(--ink); }
.member-media-settings label { font-size: 12px; color: var(--muted); }
.member-media-settings .setting-check { display: flex; align-items: center; gap: 9px; }
.private-composer .attachment-draft { margin-top: 8px; }
.private-counter { display: block; text-align: right; margin-top: 6px; color: var(--muted); font-size: 12px; }
.private-composer .send-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.private-composer textarea { font-size: 16px; border-radius: 9px; }

@media (max-width: 1100px) {
  .site-bar { padding-inline: 16px; }
  .chat-header { padding-inline: 16px; }
  .members-panel { flex-basis: 260px; }
  .message-scroll { padding: 16px; }
}
@media (max-width: 760px) {
  .site-bar { padding-inline: 12px; gap: 10px; }
  .site-bar .brand { font-size: 18px; }
  .site-actions .language-picker select { min-height: 42px; }
  .site-bar .control-link { max-width: 126px; min-height: 44px; padding: 5px 8px; font-size: 12px; }
  .app { padding: 0 8px 8px; }
  .chat-header { padding: 4px 12px; gap: 10px; }
  .room-heading { gap: 12px; }
  .chat-header .leave-button { min-height: 44px; }
  .header-actions { gap: 8px; }
  .members-toggle { display: inline-flex; }
  .members-panel { display: none; position: absolute; z-index: 12; inset: 0 0 0 auto; width: min(300px, 88%); padding: 12px 16px; border-radius: 14px 0 0 14px; }
  .chat-panel.members-open .members-panel { display: flex; }
  #closeMembersButton { flex: 0 0 44px; width: 44px; height: 44px; }
  .members-panel .members-heading { margin-bottom: 6px; }
  .message-scroll { padding: 16px 12px; }
  .message { max-width: 96%; }
  #messageForm { padding: 8px 12px max(7px, env(safe-area-inset-bottom)); }
  #messageForm #messageInput { font-size: 16px; padding-inline: 10px; }
  .action-dialog .leave-button, .action-dialog .text-button, .action-dialog .primary-button { min-height: 44px; }
}
@media (max-width: 600px) {
  .site-bar { gap: 6px; padding-inline: 10px; }
  .site-bar .brand > span:last-child { display: none; }
  .site-bar .brand-mark { width: 26px; height: 30px; }
  .site-bar .brand-mark svg { width: 26px; height: 26px; }
  .site-actions { flex: 1 1 auto; gap: 6px; justify-content: flex-end; }
  .site-actions .language-picker { padding-inline: 5px; gap: 4px; }
  .site-actions .language-picker select { max-width: 82px; font-size: 12px; }
  .site-actions .theme-picker select { max-width: 66px; }
  .site-bar .control-link { max-width: 108px; padding: 4px 7px; font-size: 11px; }
  .app { padding: 0 6px 6px; }
  .chat-header { flex-wrap: wrap; padding: 2px 12px; gap: 3px; }
  .room-heading { flex: 1 1 100%; justify-content: space-between; min-width: 0; min-height: 44px; }
  .header-actions { flex: 1 1 100%; justify-content: flex-end; min-width: 0; min-height: 44px; }
  .header-actions .members-toggle { margin-right: auto; }
  .connection-status #connectionLabel { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; white-space: normal; }
  .message-list { gap: 16px; }
  .message > .message-meta { gap: 4px 6px; }
  .community-list-row, .room-card { gap: 8px; padding-inline: 10px; }
}
@media (max-width: 420px) {
  #messageForm > .composer-row { gap: 6px; }
  #messageForm #sendButton { width: 44px; min-width: 44px; padding: 9px; }
  #messageForm #sendLabel { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
  #messageForm #sendButton svg { width: 20px; height: 20px; }
}
@media (max-width: 380px) {
  .site-actions { gap: 4px; }
  .site-actions .language-picker { padding-inline: 4px; }
  .site-actions .language-picker select { width: 70px; max-width: 70px; }
  .site-actions .theme-picker select { width: 56px; max-width: 56px; }
  .site-bar .control-link { max-width: 86px; padding-inline: 4px; }
  .chat-header { padding-inline: 10px; }
  .header-actions .leave-button { padding-inline: 8px; }
  .message { max-width: 100%; column-gap: 8px; }
  .message-scroll { padding-inline: 10px; }
  #messageForm { padding-inline: 10px; }
}
@media (max-width: 500px) {
  .private-composer .composer-row { gap: 6px; }
  .private-composer .smileys-button, .private-composer .upload-button, .private-composer .send-button { width: 44px; min-width: 44px; min-height: 44px; flex: 0 0 44px; padding: 8px; }
  .private-composer .private-send-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
  .private-composer .send-button svg { display: block; width: 20px; height: 20px; }
  .private-composer textarea { padding-inline: 9px; }
}
@media (max-height: 500px) {
  .app { padding-bottom: 6px; }
  #messageForm #messageInput { max-height: 70px; }
}
@media (pointer: coarse) and (min-width: 761px) {
  .site-actions .language-picker select { min-height: 42px; }
  .site-bar .control-link, .chat-header .leave-button { min-height: 44px; }
  .chat-header { padding-block: 4px; }
}

/* Matching non-modal chat panels share one reserved desktop column. */
:root { --side-panel-width: 260px; }
.lobby-layout { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); isolation: isolate; }
.conversation-column { grid-column: 1; grid-row: 1; }
.chat-panel:is([data-side-panel="members"], [data-side-panel="friends"], [data-side-panel="inbox"], [data-side-panel="private"], [data-side-panel="ai-private"], [data-side-panel="join-alerts"], [data-side-panel="radio"], [data-side-panel="youtube"], [data-side-panel="chat-history"]) .lobby-layout { grid-template-columns: minmax(0, 1fr) var(--side-panel-width); }
.lobby-layout > .chat-side-panel { position: relative; inset: auto; grid-column: 2; grid-row: 1; align-self: stretch; display: flex; flex-direction: column; flex: none; width: var(--side-panel-width); max-width: 100%; min-width: 0; height: auto; max-height: 100%; min-height: 0; margin: 0; padding: 12px; border: 0; border-left: 1px solid var(--line); border-radius: 0; color: var(--ink); background: var(--chat-sidebar); box-shadow: none; overflow: hidden; z-index: 3; }
.community-dialog.chat-side-panel:not([open]) { display: none; }
.chat-side-panel > .members-heading, .chat-side-panel > .dialog-heading { flex: 0 0 auto; min-height: 44px; gap: 8px; margin: 0 0 8px; }
.chat-side-panel > .dialog-heading h2, .chat-side-panel .members-heading h2 { font-size: 18px; font-weight: 600; line-height: 1.3; letter-spacing: -.25px; }
.chat-side-panel > .members-heading .icon-button, .chat-side-panel > .dialog-heading .icon-button { display: block; flex: 0 0 44px; width: 44px; height: 44px; }
.chat-side-panel > .field-hint { flex: 0 0 auto; margin: 0 0 8px; }
.chat-side-panel #communityDialogContent { flex: 1 1 auto; min-height: 0; min-width: 0; margin-top: 0; padding: 0 2px 4px 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.chat-side-panel .community-list { gap: 8px; }
.chat-side-panel .community-row { padding: 10px; font-size: 13px; }
.chat-side-panel .community-row strong { font-size: 13px; font-weight: 500; }
.chat-side-panel .community-row .count-badge { flex: 0 0 auto; }
.chat-side-panel .community-list-row { flex-direction: column; align-items: stretch; padding: 10px; gap: 8px; }
.chat-side-panel .community-list-row > button { align-self: flex-end; max-width: 100%; }
.chat-side-panel .friends-tabs { gap: 6px; }
.chat-side-panel .friends-tabs button { padding-inline: 7px; }
.chat-side-panel .leave-button, .chat-side-panel .text-button, .chat-side-panel .primary-button { min-height: 44px; }
.chat-side-panel .pagination { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; margin-top: 10px; }
.chat-side-panel .pagination > span { grid-column: 1 / -1; grid-row: 1; text-align: center; }
.chat-side-panel .pagination > button:first-child { grid-column: 1; grid-row: 2; }
.chat-side-panel .pagination > button:last-child { grid-column: 2; grid-row: 2; }
.chat-side-panel .pagination > button { min-width: 0; padding-inline: 7px; }
.chat-side-panel[data-kind="private"] #communityDialogContent { display: grid; grid-template-rows: auto auto minmax(96px, 1fr) auto; gap: 8px; }
.chat-side-panel[data-kind="private"] #communityDialogContent > .leave-button { justify-self: start; }
.chat-side-panel .private-chat-notice { margin: 0; font-size: 12px; line-height: 1.45; }
.chat-side-panel .private-chat-list { min-height: 0; height: auto; margin: 0; padding: 4px 2px; gap: 10px; }
.chat-side-panel .private-chat-list li { padding: 8px 9px; }
.chat-side-panel .private-chat-list li.attachment-message-row { padding: 5px; }
.chat-side-panel .private-composer { min-width: 0; }
.chat-side-panel .private-composer .composer-row { display: grid; grid-template-columns: 44px 44px minmax(0, 1fr); gap: 6px; align-items: end; }
.chat-side-panel .private-composer textarea { grid-column: 1 / -1; grid-row: 1; width: 100%; min-height: 56px; max-height: 100px; padding: 9px 10px; font-size: 16px; line-height: 1.4; }
.chat-side-panel .private-composer .smileys-button { grid-column: 1; grid-row: 2; font-size: 24px; }
.chat-side-panel .private-composer .upload-button { grid-column: 2; grid-row: 2; }
.chat-side-panel .private-composer .smileys-button, .chat-side-panel .private-composer .upload-button { width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 9px; border-radius: 9px; }
.chat-side-panel .private-composer .smileys-button svg, .chat-side-panel .private-composer .upload-button svg { width: 22px; height: 22px; }
.chat-side-panel .private-composer .send-button { grid-column: 3; grid-row: 2; width: auto; min-width: 44px; min-height: 44px; padding: 8px; border: 0; border-radius: 9px; color: var(--on-accent); background: var(--button); font-size: 13px; font-weight: 600; line-height: 1.3; }
.chat-side-panel .private-composer .send-button:hover:not(:disabled) { background: var(--button-hover); }
.chat-side-panel .private-composer .send-button svg { display: block; width: 18px; height: 18px; }
.chat-side-panel .private-send-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; }
.chat-side-panel .attachment-draft { flex-wrap: wrap; }
.chat-side-panel .attachment-draft > span { flex: 1 1 100%; }
.members-backdrop { display: none; }
.members-toggle[aria-expanded="true"], .composer-social-tools > button[aria-expanded="true"] { color: var(--accent-text); background: var(--accent-soft); border-color: var(--accent); }

/* Explicit sign-out remains available without taking space from the chat. */
.site-sign-out { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; gap: 6px; min-width: 36px; min-height: 36px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 500; }
.site-sign-out svg { width: 18px; height: 18px; }
@media (max-width: 760px) {
  .site-sign-out { width: 44px; min-width: 44px; min-height: 44px; padding: 10px; }
  .site-sign-out-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
}
@media (max-width: 680px) {
  .lobby-layout, .chat-panel:is([data-side-panel="members"], [data-side-panel="friends"], [data-side-panel="inbox"], [data-side-panel="private"], [data-side-panel="ai-private"], [data-side-panel="join-alerts"], [data-side-panel="radio"], [data-side-panel="youtube"], [data-side-panel="chat-history"]) .lobby-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto; }
  .conversation-column { display: contents; }
  .restriction-notice { grid-column: 1; grid-row: 1; }
  .connection-notice { grid-column: 1; grid-row: 2; }
  .conversation-frame { grid-column: 1; grid-row: 3; }
  #messageForm { grid-column: 1; grid-row: 4; }
  .lobby-layout > .chat-side-panel { grid-column: 1; grid-row: 1 / 4; justify-self: end; width: min(var(--side-panel-width), 100%); box-shadow: -8px 0 24px #1b2c5614; z-index: 5; }
}
@media (max-width: 380px) {
  .site-bar:has(.site-sign-out:not([hidden])) .brand { display: none; }
}
@media (pointer: coarse) and (min-width: 761px) {
  .site-sign-out { min-width: 44px; min-height: 44px; }
}

/* v0.7.3: a compact, left-aligned conversation on every screen. */
.message-list { gap: 8px; }
.message-list .message, .private-chat-list .message, .message-list .message.own, .private-chat-list .message.own {
  display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 6px; align-self: flex-start; align-items: start; justify-items: start;
  width: fit-content; max-width: 100%; min-width: 0; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--ink);
}
.message-list .message > .message-avatar, .private-chat-list .message > .message-avatar { grid-column: 1; grid-row: 1; width: 24px; height: 24px; margin-top: 2px; border-radius: 7px; font-size: 11px; }
.message-line { grid-column: 2; min-width: 0; max-width: 100%; padding: 3px 6px; border-radius: 7px; line-height: 1.55; overflow-wrap: anywhere; }
.message.own .message-line { background: var(--chat-outgoing); }
.message .message-meta { display: inline; margin: 0; white-space: normal; }
.message .message-name { display: inline; padding: 0; color: var(--ink); font-size: 12px; font-weight: 600; line-height: inherit; }
.message .member-rank-icon { display: inline-grid; grid-column: auto; width: 17px; height: 20px; margin: 0 3px 0 4px; vertical-align: -5px; }
.message .rank-symbol { width: 16px; height: 18px; font-size: 10px; }
.message .member-rank-icon[data-rank="vip"] .rank-symbol, .message .member-rank-icon[data-rank="vip_plus"] .rank-symbol { width: 18px; height: 18px; font-size: 7px; }
.message .member-rank-icon[data-rank="guest"] .rank-symbol, .message .member-rank-icon[data-rank="register"] .rank-symbol { width: 16px; height: 16px; font-size: 9px; }
.message .member-rank-icon .rank-decoration { top: -3px; right: -2px; font-size: 8px; }
.message .member-rank-icon[data-rank="webmaster"] .rank-decoration { right: 3px; top: -3px; font-size: 9px; }
.message-colon { margin-right: 3px; font-size: 12px; }
:root { --message-text-size: 13px; }
:root[data-message-size="small"] { --message-text-size: 12px; }
:root[data-message-size="large"] { --message-text-size: 15px; }
.message .message-body, .private-chat-list .message .message-body { display: inline; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--ink); font-size: var(--message-text-size); line-height: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }
.message .message-time, .private-chat-list .message time { display: inline-block; margin: 0 0 0 6px; font-size: 10px; line-height: 1.4; vertical-align: baseline; }
.message .message-body.sticker-message { display: inline-block; padding: 3px 4px; font-size: 34px; vertical-align: middle; }
.message .sticker-message small { font-size: 10px; }
.message .message-body.attachment-message { max-width: 100%; }
.message .message-attachment { max-width: 100%; margin: 4px 0; }
.message .message-attachment img { display: block; max-width: min(100%, 175px); max-height: 175px; width: auto; height: auto; object-fit: contain; border-radius: 5px; }
.message .attachment-card.attachment-image { display: block; width: fit-content; max-width: 175px; max-height: 175px; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.message-actions { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 3px; margin: 0 0 0 4px; vertical-align: middle; }
.message.has-media .message-actions { display: flex; flex-direction: column; align-items: flex-start; max-width: 100%; margin: 2px 0 0; }
.message-action-primary { display: inline-flex; align-items: center; flex-wrap: nowrap; gap: 3px; max-width: 100%; }
.message-action-primary .message-time { flex: 0 0 auto; margin-left: 3px; }
.message-action-primary .message-action-button { flex: 0 0 auto; padding-inline: 4px; }
.message-reactions { display: inline-flex; flex-wrap: wrap; gap: 3px; max-width: 100%; }
.message-action-button { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; min-height: 28px; padding: 3px 6px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 400; line-height: 1.3; }
.message-action-button:hover, .message-action-button[aria-expanded="true"] { color: var(--accent-text); background: var(--accent-soft); }
.message-action-button.remove-action { font-size: 17px; }
.message-action-button.remove-action:hover { color: var(--error); background: var(--error-bg); }
.reaction-choices { display: inline-flex; flex-wrap: wrap; gap: 1px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.reaction-choices .message-action-button { padding: 4px; font-size: 16px; }
.message-reaction { min-height: 25px; padding: 2px 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); font-size: 11px; }
.message-reaction[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.message-quote { display: flex; flex-direction: column; gap: 2px; margin: 0 0 4px; padding: 4px 7px; border-left: 2px solid var(--accent); border-radius: 3px; background: var(--subtle); color: var(--muted); font-size: 11px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-quote strong { color: var(--ink); font-size: 11px; font-weight: 500; }
.reply-draft { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; padding: 5px 7px; border-left: 2px solid var(--accent); border-radius: 5px; background: var(--subtle); font-size: 11px; }
.reply-draft-copy { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.reply-draft-copy small { display: block; margin-top: 2px; color: var(--muted); }
.draft-recovery { margin: 0 0 6px; color: var(--muted); font-size: 11px; }
.draft-recovery summary { cursor: pointer; color: var(--accent-text); }
.draft-recovery .recovered-draft { display: block; width: 100%; min-height: 64px; max-height: 130px; margin: 5px 0; padding: 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--field); color: var(--ink); font-size: 16px; resize: vertical; }
.draft-recovery .text-button { margin-right: 10px; min-height: 28px; font-size: 11px; }
.photo-dialog { width: fit-content; max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); padding: 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--surface); overflow: auto; box-shadow: 0 16px 50px #10233b30; }
.photo-dialog::backdrop { background: #11244280; }
.photo-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; max-width: 325px; margin-bottom: 7px; font-size: 11px; }
#photoTitle { min-width: 0; overflow-wrap: anywhere; }
.photo-heading .icon-button { flex: 0 0 32px; width: 32px; height: 32px; }
#photoImage { display: block; width: auto; height: auto; max-width: min(325px, calc(100vw - 48px)); max-height: min(325px, calc(100dvh - 110px)); margin: auto; border-radius: 5px; object-fit: contain; }
#messageForm .composer-footer { position: relative; flex-wrap: wrap; gap: 5px; }
.composer-social-tools { position: relative; gap: 6px; }
.composer-footer > .counter { margin-left: auto; white-space: nowrap; font-size: 11px; }
.chat-options { position: absolute; z-index: 10; left: 0; bottom: calc(100% + 8px); min-width: 140px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 8px 22px #152d5920; }
.chat-options .leave-button { width: 100%; text-align: start; border: 0; min-height: 40px; }
.room-title-group { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.message-size-options { display: inline-flex; gap: 1px; padding: 2px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.message-size-options button { display: inline-flex; justify-content: center; align-items: center; width: 26px; min-height: 28px; padding: 2px; border: 0; border-radius: 4px; color: var(--muted); background: transparent; font-size: 11px; line-height: 1; }
.message-size-options button[aria-pressed="true"] { color: var(--accent-text); background: var(--accent-soft); font-weight: 600; }
@media (pointer: coarse) { .message-size-options button { min-height: 32px; } }
.radio-panel, .youtube-search { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.radio-controls { display: flex; gap: 8px; }
.radio-controls > button { flex: 1; }
.radio-volume { display: flex; flex-direction: column; gap: 8px; font-size: 12px; }
.radio-volume input { width: 100%; accent-color: var(--accent); }
.youtube-search label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.youtube-search input { width: 100%; min-width: 0; min-height: 42px; padding: 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--field); color: var(--ink); font-size: 16px; }
.youtube-search a { display: inline-block; align-self: start; color: var(--accent-text); }
.radio-settings { margin-top: 14px; }
.radio-settings .form-field { margin: 12px 0; }
@media (max-width: 380px) {
  .composer-social-tools { gap: 4px; }
  .composer-social-tools > button { flex-basis: 40px; width: 40px; min-width: 40px; height: 40px; min-height: 40px; padding: 8px; }
}
@media (pointer: coarse) {
  .message-actions { gap: 4px; }
  .message-action-button { min-height: 32px; min-width: 32px; }
}

.chat-side-panel .private-chat-list .message { padding: 0; }

/* v0.7.4: a single identity, compact profile actions and public Wall. */
.community-dialog[data-kind="profile"] { width: min(430px, calc(100vw - 20px)); padding: 14px; }
.community-dialog[data-kind="profile"] > .dialog-heading { margin-bottom: 8px; }
.community-dialog[data-kind="profile"] #communityDialogStatus:empty { display: none; }
.profile-hero { overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--subtle); }
.profile-cover { height: 108px; overflow: hidden; background: linear-gradient(115deg, var(--accent-soft), var(--surface)); }
.profile-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.profile-identity { display: flex; align-items: center; gap: 10px; padding: 9px 11px; }
.profile-avatar { display: grid; place-items: center; flex: 0 0 48px; width: 48px; height: 48px; border: 2px solid var(--surface); border-radius: 12px; background: var(--chat-avatar); color: var(--chat-avatar-ink); font-size: 19px; font-weight: 600; overflow: hidden; }
.profile-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.profile-identity-text { min-width: 0; }
.profile-identity-text h3 { margin: 0 0 4px; font-size: 16px; line-height: 1.35; font-weight: 600; overflow-wrap: anywhere; }
.profile-presence { display: inline-block; margin-left: 7px; color: var(--muted); font-size: 11px; }
.profile-presence[data-presence="online"] { color: var(--success); }
.profile-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; margin: 8px 0; }
.profile-action { min-width: 0; min-height: 36px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: var(--surface); font-size: 11px; font-weight: 400; line-height: 1.3; overflow-wrap: anywhere; }
.profile-action:hover { border-color: var(--accent); color: var(--accent-text); }
.profile-more { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 8px; }
.profile-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 0 0 10px; padding-bottom: 7px; border-bottom: 1px solid var(--line); }
.profile-tabs .profile-action { min-height: 34px; font-size: 12px; }
.profile-tabs [aria-selected="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.profile-tab-content { min-width: 0; }
.profile-facts { display: grid; grid-template-columns: minmax(60px, auto) minmax(0, 1fr); gap: 7px 12px; margin: 0 0 8px; font-size: 12px; line-height: 1.4; }
.profile-facts dt { color: var(--muted); }.profile-facts dd { margin: 0; overflow-wrap: anywhere; }
.profile-about { margin: 0 0 11px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.profile-editor { display: flex; flex-direction: column; gap: 10px; }.profile-editor > .field-hint { margin: 0; }
.profile-edit-row { display: flex; align-items: end; gap: 8px; }.profile-edit-row > label:first-child { display: flex; flex: 1; flex-direction: column; min-width: 0; gap: 5px; font-size: 12px; color: var(--muted); }
.profile-edit-row input:not([type="checkbox"]), .profile-edit-row select, .profile-edit-row textarea { width: 100%; min-width: 0; min-height: 38px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--field); color: var(--ink); font-size: 16px; line-height: 1.35; }
.profile-edit-row textarea { min-height: 76px; resize: vertical; }
.profile-public-choice { display: inline-flex; align-items: center; flex: 0 0 auto; gap: 5px; min-height: 38px; color: var(--muted); font-size: 11px; }
.profile-public-choice input { accent-color: var(--accent); }
.profile-cover-tools, .profile-editor-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }.profile-cover-tools .field-hint { flex-basis: 100%; margin: 0; overflow-wrap: anywhere; }
.profile-editor .avatar-editor { display: flex; flex-direction: row; flex-wrap: wrap; gap: 6px; align-items: center; }.profile-editor .avatar-editor > strong { font-size: 12px; }.profile-editor .avatar-editor small { flex-basis: 100%; }
.profile-editor .primary-button, .wall-composer .primary-button { min-height: 36px; padding: 6px 11px; font-size: 12px; }
.profile-editor .avatar-editor button { min-height: 36px; padding: 5px 8px; font-size: 12px; }
.profile-gift { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--subtle); font-size: 13px; }.profile-gift-icon { font-size: 24px; }
.wall-composer { padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
.wall-composer textarea { display: block; width: 100%; min-height: 72px; max-height: 180px; resize: vertical; margin-bottom: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--field); color: var(--ink); font-size: 16px; line-height: 1.4; }
.wall-composer-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }.wall-composer-tools .counter { margin-left: auto; font-size: 10px; }
.wall-selected-file { display: flex; align-items: center; gap: 8px; font-size: 11px; overflow-wrap: anywhere; }.wall-selected-file > span { flex: 1; min-width: 0; }
.profile-wall-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.wall-post { min-width: 0; padding: 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--subtle); }
.wall-post-text { margin: 0 0 7px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.wall-photo { display: block; width: fit-content; max-width: 100%; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.wall-photo img { display: block; width: auto; height: auto; max-width: min(175px, 100%); max-height: 175px; border-radius: 5px; object-fit: contain; }
.wall-file { display: block; color: var(--accent-text); font-size: 12px; overflow-wrap: anywhere; }
.wall-post-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 5px; color: var(--muted); font-size: 10px; }
.wall-audio { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }.wall-audio-name { flex: 1 0 100%; font-size: 12px; overflow-wrap: anywhere; }.wall-audio button { min-width: 48px; }
.wall-pagination { display: flex; justify-content: space-between; align-items: center; gap: 5px; margin: 10px 0 0; }.wall-pagination span { color: var(--muted); font-size: 11px; text-align: center; }

/* Compact operational consoles share the current theme and keep media bounded. */
.console-toolbar { display: flex; align-items: end; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.console-toolbar .form-field { flex: 1 1 130px; min-width: 0; margin: 0; }
.console-toolbar .form-field.console-search { flex-basis: 240px; }
.console-toolbar button, .console-actions button { min-height: 34px; padding: 7px 11px; font-size: 12px; }
.console-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 9px 0; }
.console-summary { display: flex; flex-wrap: wrap; gap: 12px; margin: 10px 0 14px; color: var(--muted); font-size: 12px; }
.trivia-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 320px); gap: 14px; align-items: start; }
.trivia-bank, .trivia-editor, .trivia-game-settings, .trivia-import, .private-review-list, .private-review-thread { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.trivia-bank-list, .review-conversations, .review-messages { list-style: none; margin: 0; padding: 0; }
.trivia-question-row { display: flex; gap: 7px; align-items: start; padding: 9px 0; border-bottom: 1px solid var(--line); }
.trivia-question-select { flex: 1; min-width: 0; padding: 0; border: 0; background: transparent; color: var(--ink); text-align: start; }
.trivia-question-select strong { display: block; overflow-wrap: anywhere; font-size: 13px; line-height: 1.4; font-weight: 500; }
.trivia-question-select small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.trivia-editor h3, .trivia-game-settings h3, .trivia-import h3 { margin: 0 0 12px; font-size: 16px; }
.trivia-editor .form-field, .trivia-game-settings .form-field { margin-bottom: 9px; }
.trivia-editor textarea, .trivia-game-settings input, .trivia-game-settings select { width: 100%; }
.trivia-editor textarea { min-height: 74px; resize: vertical; }
.trivia-compact-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.trivia-import { margin: 12px 0; }
.trivia-import-preview { max-height: 260px; overflow: auto; }
.trivia-import-preview table { width: 100%; border-collapse: collapse; font-size: 12px; }
.trivia-import-preview th, .trivia-import-preview td { padding: 7px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; overflow-wrap: anywhere; }
.trivia-game-settings { margin-top: 14px; }
.room-trivia { margin: 8px 12px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--accent-soft); color: var(--ink); }
.room-trivia-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; font-size: 11px; color: var(--muted); }
.room-trivia-question { margin: 6px 0; font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.room-trivia-score { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; font-size: 11px; }
.room-trivia form { display: flex; align-items: start; gap: 7px; margin-top: 7px; }
.room-trivia input { min-width: 0; flex: 1; min-height: 34px; }
.room-trivia button { min-height: 34px; padding: 6px 11px; font-size: 12px; }
.private-review-layout { display: grid; grid-template-columns: minmax(220px, 290px) minmax(0, 1fr); gap: 14px; align-items: start; }
.review-conversations button { display: block; width: 100%; padding: 10px 5px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--ink); text-align: start; }
.review-conversations button[aria-pressed="true"] { background: var(--accent-soft); }
.review-conversations strong, .review-conversations small { display: block; overflow-wrap: anywhere; }
.review-conversations strong { font-size: 12px; font-weight: 500; }.review-conversations small { margin-top: 4px; font-size: 10px; color: var(--muted); }
.review-message { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; overflow-wrap: anywhere; }
.review-message header { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-bottom: 4px; font-size: 11px; }
.review-message time { color: var(--muted); font-size: 10px; }.review-message p { margin: 4px 0; white-space: pre-wrap; }
.review-photo { display: block; width: fit-content; max-width: 175px; max-height: 175px; padding: 0; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--subtle); }
.review-photo img { display: block; width: auto; height: auto; max-width: 175px; max-height: 175px; object-fit: contain; }
.review-photo-footer { display: flex; flex-wrap: nowrap; align-items: center; gap: 7px; max-width: 175px; margin-top: 5px; color: var(--muted); font-size: 10px; }
.review-photo-footer > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.review-photo-footer time { flex: 0 0 auto; white-space: nowrap; }
@media (max-width: 1020px) { .trivia-layout { grid-template-columns: minmax(0, 1fr); }.trivia-editor { max-width: none; } }
@media (max-width: 760px) { .private-review-layout { grid-template-columns: minmax(0, 1fr); }.review-conversations { max-height: 230px; overflow: auto; }.room-trivia { margin: 6px 8px; }.console-toolbar { gap: 6px; } }
@media (pointer: coarse) { .profile-action { min-height: 40px; }.profile-tabs .profile-action { min-height: 38px; } }
@media (max-width: 380px) { .profile-actions { gap: 4px; }.profile-actions .profile-action { padding-inline: 3px; font-size: 10px; }.profile-cover { height: 94px; } }

/* v0.7.6: one compact bottom-left options panel in chat and before login. */
.entry-menu-button { position: fixed; z-index: 40; left: max(12px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom)); background: var(--surface); }
.chat-options { position: fixed; z-index: 60; width: 244px; max-width: calc(100vw - 16px); min-width: 0; left: 12px; bottom: 64px; padding: 8px; max-height: calc(var(--app-height) - 100px); overflow-y: auto; box-shadow: 0 8px 24px #152d5930; }
.chat-options .menu-setting { display: flex; align-items: center; gap: 8px; border: 0; padding: 0 8px; min-height: 44px; }
.chat-options .menu-setting-label { flex: 1; color: var(--ink); font-size: 12px; font-weight: 500; }
.chat-options .menu-setting select { color: var(--ink); min-height: 44px; max-width: 112px; font-size: 13px; }
.chat-options .control-link, .chat-options .site-sign-out { width: 100%; max-width: none; text-align: start; min-height: 44px; justify-content: flex-start; padding: 8px; }
.chat-options .site-sign-out-label { display: inline; }
.chat-options #leaveButton, .chat-options .site-sign-out { margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); border-radius: 0; }

/* Approval requests and official YouTube playback in the compact drawer. */
.friends-navigation .friends-tabs { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; }
.friend-request { display:flex; flex-direction:column; gap:8px; padding:9px; border:1px solid var(--line); border-radius:8px; }
.friend-request-identity { display:flex; flex-direction:column; gap:3px; min-width:0; }
.friend-request-identity small { color:var(--muted); font-size:11px; }
.friend-request-actions { display:flex; flex-wrap:wrap; align-items:center; gap:6px; }
.friend-request-actions button { min-height:36px; padding:6px 9px; font-size:12px; }
.friend-pending { color:var(--muted); font-size:12px; align-self:center; }
.friend-notifications .friend-notification { display:flex; flex-direction:column; align-items:stretch; gap:7px; }
.friend-notification > button { align-self:flex-start; }
.youtube-search { gap:8px; }
.youtube-search button { min-height:40px; font-size:13px; }
.youtube-player { display:flex; flex-direction:column; gap:8px; min-width:200px; }
.youtube-player:empty { display:none; }
.youtube-player > strong { font-size:12px; font-weight:600; overflow-wrap:anywhere; }
.youtube-frame { display:block; width:100%; min-width:200px; height:200px; min-height:200px; border:0; background:#000; }
.youtube-player .text-button { align-self:flex-start; color:var(--accent-text); }
.youtube-results { list-style:none; display:flex; flex-direction:column; gap:8px; padding:0; margin:0; }
.youtube-result { display:flex; align-items:flex-start; gap:8px; width:100%; padding:7px; text-align:start; border:1px solid var(--line); border-radius:7px; color:var(--ink); background:var(--surface); }
.youtube-result img { display:block; flex:none; width:80px; height:45px; object-fit:cover; border-radius:3px; }
.youtube-result > span { display:flex; flex-direction:column; gap:4px; min-width:0; }
.youtube-result strong { font-size:12px; font-weight:500; line-height:1.35; overflow-wrap:anywhere; }
.youtube-result small { font-size:11px; color:var(--muted); overflow-wrap:anywhere; }
.remember-login { display:grid; gap:3px; margin:2px 0 4px; }
.remember-login-option { display:flex !important; align-items:center; gap:9px; min-height:40px; cursor:pointer; }
.remember-login-option input[type="checkbox"] { flex:none; width:19px; height:19px; min-height:0; margin:0; padding:0; accent-color:var(--accent); }
.remember-login .field-hint { margin:0; padding-inline-start:28px; }
.youtube-search input { width:100%; min-width:0; min-height:44px; font-size:16px; }
.youtube-external-search { display:flex; align-items:center; justify-content:center; min-height:44px; padding:10px 14px; text-decoration:none; text-align:center; }
.youtube-search .youtube-external-search { color:var(--on-accent); }
.youtube-external-search[aria-disabled="true"] { opacity:.6; pointer-events:none; }
.youtube-share { display:grid; gap:10px; padding:13px; border:1px solid var(--line); border-radius:12px; background:var(--surface); }
.youtube-share label { display:grid; gap:6px; color:var(--ink); font-size:13px; font-weight:600; }
.youtube-share select { width:100%; min-width:0; min-height:44px; padding:9px; border:1px solid var(--line); border-radius:8px; background:var(--field); color:var(--ink); font:inherit; font-size:16px; }
.youtube-share .primary-button { min-height:44px; white-space:normal; overflow-wrap:anywhere; }
.youtube-share .field-hint { margin:0; }
.youtube-message-card { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:7px 12px; align-items:center; min-width:0; padding:3px 0; }
.youtube-message-card strong { font-size:14px; font-weight:600; }
.youtube-message-play { min-height:40px; padding:7px 11px; border:1px solid var(--line); border-radius:9px; color:var(--accent-text); background:var(--surface); font:inherit; font-size:14px; cursor:pointer; }
.youtube-message-link { grid-column:1/-1; color:var(--muted); font-size:12px; overflow-wrap:anywhere; }
.youtube-message-play:focus-visible,.youtube-external-search:focus-visible { outline:2px solid var(--accent); outline-offset:3px; }
.youtube-settings select,.youtube-settings input[type="password"] { min-width:0; width:100%; min-height:42px; border:1px solid var(--line); border-radius:7px; background:var(--field); color:var(--ink); padding:8px; }

/* v0.7.7: trusted bot messages retain the reader's S / M / L preference. */
.bot-message .bot-badge, .bot-member .bot-badge { display:inline-block; padding:1px 5px; border-radius:4px; color:var(--accent-text); background:var(--accent-soft); font-size:10px; font-weight:600; line-height:1.4; }
.members-panel .bot-member .bot-badge { grid-column:3 / -1; justify-self:end; }
.members-panel .bot-member .member-avatar { font-size:17px; }
.ai-saved-status { padding:10px 12px; border:1px solid var(--line); border-radius:8px; background:var(--subtle); overflow-wrap:anywhere; }
.ai-saved-status h3 { margin:0 0 6px; font-size:14px; }
.ai-status-state { margin:4px 0; font-size:13px; font-weight:600; }
.message.bot-trivia .message-body { font-weight:700; }
.bot-message .message-avatar { font-size:17px; }
.history-navigation { display:flex; align-items:center; justify-content:space-between; gap:6px; }
.history-navigation button { min-height:34px; padding:5px 9px; font-size:12px; }
.history-message-list { min-height:0; overflow-y:auto; overscroll-behavior:contain; max-height:65vh; margin:0; padding:6px 0; }
.history-message-list .message { margin-bottom:8px; }
.history-message-list .message-line { min-width:0; }
.history-message-list .attachment-image { max-width:175px; max-height:175px; }
.history-message-list .attachment-image img { max-width:175px; max-height:175px; width:auto; height:auto; object-fit:contain; }
.chat-side-panel[data-kind="chat-history"] #communityDialogContent { display:flex; flex-direction:column; gap:7px; min-height:0; }
.ai-settings { display:grid; gap:14px; margin-top:18px; min-width:0; }
.ai-room-picker { display:flex; flex-wrap:wrap; gap:10px 18px; margin:0; padding:12px; border:1px solid var(--line); border-radius:8px; min-width:0; }
.ai-room-picker legend { padding:0 5px; font-size:13px; font-weight:600; }
.ai-room-picker .form-field { flex-direction:row; align-items:center; gap:8px; font-size:12px; }
.ai-settings input, .ai-settings select, .ai-settings textarea { width:100%; min-width:0; min-height:38px; border:1px solid var(--line); border-radius:7px; padding:8px; color:var(--ink); background:var(--field); font-size:13px; }
.ai-settings input[type="checkbox"] { width:20px; height:20px; min-height:20px; accent-color:var(--button); }
.ai-settings textarea { min-height:110px; resize:vertical; }
.ai-settings .trivia-compact-fields { grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr)); }
.ai-connection { display:grid; gap:8px; margin-top:14px; padding:12px; border:1px solid var(--line); border-radius:8px; background:var(--subtle); min-width:0; overflow-wrap:anywhere; }
.ai-connection h3 { margin:0; font-size:14px; }
.ai-connection > button { justify-self:start; }
.ai-credentials, .ai-key-form { display:grid; gap:8px; min-width:0; }
.ai-key-form { margin:0; }
.ai-key-form input { min-width:0; width:100%; }
.ai-credentials .field-hint, .ai-credentials .field-error { margin:0; }
.ai-test-result { white-space:pre-wrap; overflow-wrap:anywhere; font-size:13px; }
.ai-test-result > p:not(.field-hint):not(.field-error) { padding:10px; border-radius:7px; background:var(--accent-soft); }
.ai-activity { flex:0 0 auto; margin:4px 12px; padding:5px 8px; color:var(--muted); font-size:12px; line-height:1.4; }
.ai-answer { white-space:pre-wrap; overflow-wrap:anywhere; }
.ai-citation { display:inline; padding:0 2px; color:var(--accent-text); font-size:.9em; font-weight:700; text-decoration:underline; text-underline-offset:2px; }
.ai-citation:focus-visible, .ai-source-title:focus-visible { outline:2px solid var(--accent); outline-offset:2px; border-radius:2px; }
.ai-sources { display:flex; flex-wrap:wrap; gap:3px 7px; max-width:100%; margin:4px 0; color:var(--muted); font-size:11px; line-height:1.45; white-space:normal; }
.ai-sources-label { font-weight:600; }
.ai-source-title { max-width:100%; color:var(--accent-text); overflow-wrap:anywhere; text-decoration:underline; text-underline-offset:2px; }
.ai-capabilities { min-width:0; margin-top:14px; padding:12px; border:1px solid var(--line); border-radius:8px; }
.ai-capabilities h3 { margin:0 0 8px; font-size:15px; }
.ai-capability-settings { grid-template-columns:repeat(auto-fit,minmax(min(100%,330px),1fr)); gap:12px; margin-top:12px; }
.ai-capability-settings > button { grid-column:1 / -1; justify-self:start; }
.ai-capability-row { min-width:0; margin:0; padding:10px; border:1px solid var(--line); border-radius:7px; overflow-wrap:anywhere; }
.ai-capability-row legend { padding:0 5px; font-size:14px; font-weight:600; }
.ai-capability-row .field-hint, .ai-capability-row .field-error { margin:5px 0; }
.ai-capability-fields { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.ai-capability-fields .form-field { min-width:0; font-size:12px; }
.ai-capability-ready { margin:8px 0 4px; font-size:12px; font-weight:600; }
.youtube-test { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px; align-items:end; padding-top:12px; border-top:1px solid var(--line); }
.youtube-test > p { grid-column:1/-1; margin:0; }
@media (max-width:700px) { .youtube-test { grid-template-columns:minmax(0,1fr); } }

@media (max-width:700px) {
  .ai-settings input, .ai-settings select, .ai-settings textarea { font-size:16px; }
}

/* The AI and join-alert views use the same compact right panel as private chat. */
.chat-options :is(#askAIButton,#aiPrivateButton,#joinAlertsButton) { width:100%; min-height:44px; text-align:start; padding:8px; }
.chat-side-panel[data-kind="ai-private"] #communityDialogContent { display:flex; flex-direction:column; gap:8px; overflow:hidden; }
.ai-private-list { flex:1 1 auto; overflow-y:auto; min-height:100px; overflow-wrap:anywhere; }
.ai-private-message header { display:flex; flex-wrap:wrap; align-items:baseline; gap:6px; font-size:11px; }
.ai-private-message header strong { font-size:12px; }
.ai-private-message header time { color:var(--muted); font-size:10px; }
.ai-private-message p { margin:6px 0; font-size:13px; line-height:1.5; white-space:pre-wrap; overflow-wrap:anywhere; }
.ai-private-message.own-message { background:var(--accent-soft); }
.ai-private-message .attachment-image, .ai-private-message .attachment-image img { max-width:175px; max-height:175px; object-fit:contain; }
.ai-private-composer { display:grid; gap:6px; flex:none; }
.ai-private-composer textarea { width:100%; min-width:0; min-height:56px; max-height:100px; padding:9px 10px; resize:vertical; border:1px solid var(--line); border-radius:9px; color:var(--ink); background:var(--field); font:inherit; font-size:16px; line-height:1.4; }
.ai-private-tools { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:6px; }
.ai-private-tools select { min-width:0; width:100%; min-height:44px; padding:8px; border:1px solid var(--line); border-radius:9px; color:var(--ink); background:var(--field); font:inherit; font-size:13px; }
.ai-private-tools .send-button { width:auto; min-height:44px; padding:8px 12px; }
.ai-private-composer .field-hint { margin:0; }
.ai-inbox-row { display:flex; flex-direction:column; align-items:flex-start; gap:4px; }
.join-alert-form { display:grid; gap:6px; }
.join-alert-form input, .join-alert-form select { width:100%; min-width:0; min-height:44px; font-size:16px; }
.join-alert-list .unread { background:var(--accent-soft); }
.join-alert-toast { position:absolute; right:12px; bottom:144px; z-index:12; display:flex; align-items:center; flex-wrap:wrap; gap:7px; width:min(350px,calc(100% - 24px)); padding:10px; border:1px solid var(--line); border-radius:9px; background:var(--chat-sidebar); color:var(--ink); box-shadow:0 4px 18px #0003; font-size:13px; }
.join-alert-toast > span { flex:1 1 100%; overflow-wrap:anywhere; }
.join-alert-toast button { min-height:44px; }
.ai-feature-settings, .ai-private-review { border:1px solid var(--line); border-radius:8px; padding:12px; margin-top:14px; min-width:0; }
.ai-feature-settings h3, .ai-private-review h3 { margin:0 0 10px; font-size:16px; }
.ai-private-review .ai-private-list { max-height:440px; padding:4px; }
.ai-settings input[aria-invalid="true"] { outline:2px solid var(--error,#b92435); outline-offset:1px; }
.ai-settings .form-field .field-hint, .ai-settings .form-field .field-error { margin:0; font-size:11px; }

/* Keep a reading position stable while older private messages are prepended. */
.private-chat-list { overflow-anchor:none; overscroll-behavior:contain; }
.chat-side-panel[data-kind="ai-private"] #communityDialogStatus:empty, .chat-side-panel[data-kind="private"] #communityDialogStatus:empty { display:none; }
.chat-side-panel[data-kind="ai-private"] .ai-private-list { min-height:96px; }
.chat-side-panel .ai-private-message { max-width:100%; }
.ai-private-message .attachment-image img { width:auto; height:auto; }
.ai-private-composer textarea:disabled, .ai-private-tools select:disabled { opacity:.6; }
.ai-private-composer textarea:focus, .ai-private-tools select:focus { outline:2px solid var(--accent); outline-offset:2px; }

/* Mobile conversation refresh: one room header, grouped messages and quiet tools.
   Only the active chat replaces the separate brand strip; account views retain it. */
body[data-view="chat"] { --bar-height: 0px; }
body[data-view="chat"] > .site-bar { display: none; }
body[data-view="chat"] > .app { padding: 10px; }
/* Active mobile chat follows Safari's visible viewport, including keyboard
   panning. Its existing grid owns the timeline and composer; the document does
   not become a second chat scroller. The binding is disabled for pinch zoom
   and ordinary account/admin views. */
:root[data-chat-viewport="true"], :root[data-chat-viewport="true"] body { overflow: hidden; overscroll-behavior-y: none; }
:root[data-chat-viewport="true"] body[data-view="chat"] > .app {
  position: fixed; top: var(--app-top, 0px); right: 0; left: 0;
  height: var(--app-height); margin: 0; padding: 0;
}
:root[data-chat-viewport="true"] #chatView { border: 0; border-radius: 0; }
#chatView .chat-header { flex-wrap: nowrap; min-height: 70px; gap: 12px; padding: 10px 16px; }
#chatView .room-heading { flex: 1 1 auto; min-width: 0; min-height: 0; gap: 9px; justify-content: flex-start; }
.room-brand-mark { display: grid; place-items: center; flex: 0 0 30px; width: 30px; height: 32px; color: var(--accent); }
.room-brand-mark svg { width: 29px; height: 29px; }
.room-title-copy { flex: 1 1 auto; min-width: 0; }
#chatView .room-heading h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 20px; line-height: 1.2; font-weight: 650; }
#chatView .connection-status { display: flex; align-items: center; gap: 5px; margin-top: 4px; font-size: 11px; line-height: 1.3; color: var(--muted); }
#chatView .connection-status #connectionLabel { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; white-space: normal; }
#chatView .room-navigation { display: flex; align-items: center; justify-content: flex-end; flex: 0 0 auto; gap: 7px; min-width: 0; margin-inline-start: auto; }
#chatView .room-navigation .leave-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; min-height: 44px; padding: 7px 9px; border-radius: 9px; color: var(--ink); font-size: 12px; line-height: 1.3; white-space: nowrap; }
#chatView .rooms-button > svg { width: 15px; height: 15px; }
#chatView .rooms-button .room-chevron { width: 12px; height: 12px; margin: 0; }
#chatView .room-navigation .count-badge { display: inline-grid; place-items: center; min-width: 19px; min-height: 19px; padding: 1px 5px; border-radius: 5px; font-size: 11px; line-height: 1.2; }
.chat-options .message-size-setting { flex-direction: column; align-items: stretch; gap: 7px; padding: 8px; }
.message-size-setting .message-size-options { display: flex; width: 100%; }
.message-size-setting .message-size-options button { flex: 1 1 0; width: auto; min-width: 44px; min-height: 44px; font-size: 13px; }

/* Keep every existing composer shortcut, with visible labels and generous targets. */
#messageForm { padding: 10px 14px 7px; }
#messageForm > .composer-row { align-items: flex-end; gap: 7px; }
#messageForm .composer-tools > button, #messageForm .upload-button, #messageForm #sendButton { flex: 0 0 44px; width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 10px; border-radius: 10px; }
#messageForm #sendButton { position: relative; }
#messageForm #sendButton svg { display: block; width: 21px; height: 21px; }
#messageForm #sendLabel { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
#messageForm #messageInput { height: 44px; min-height: 44px; max-height: 132px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 16px; line-height: 22px; box-shadow: none; }
#messageForm #messageInput:focus, #messageForm #messageInput:focus-visible { border-color: var(--accent); outline: none; box-shadow: 0 0 0 1px var(--accent); }
#messageForm #messageInput[aria-invalid="true"] { border-color: var(--error); }
#messageForm #messageInput[aria-invalid="true"]:focus { box-shadow: 0 0 0 1px var(--error); }
/* Long drafts scroll inside the input on a short visual viewport, reserving
   space for the conversation, header and the complete shortcut toolbar. */
:root[data-chat-viewport="true"] #messageForm #messageInput { max-height: clamp(44px, calc(var(--app-height) - 300px), 132px); }
@media (max-height: 500px) {
  :root[data-chat-viewport="true"] #messageForm #messageInput { max-height: clamp(44px, calc(var(--app-height) - 300px), 70px); }
}
#messageForm .composer-footer { flex-wrap: nowrap; align-items: center; min-height: 48px; margin-top: 6px; gap: 6px; }
#messageForm .composer-social-tools { display: flex; align-items: center; flex: 1 1 auto; gap: 2px; min-width: 0; }
#messageForm .composer-social-tools > .communication-button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; flex: 0 1 54px; width: 54px; min-width: 44px; min-height: 48px; height: 48px; padding: 4px 2px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--accent-text); }
#messageForm .composer-social-tools > .communication-button:hover:not(:disabled), #messageForm .composer-social-tools > .communication-button[aria-expanded="true"] { border-color: transparent; background: var(--accent-soft); }
#messageForm .composer-social-tools > .communication-button svg { width: 21px; height: 21px; }
#messageForm .toolbar-label { display: block; max-width: 100%; color: var(--ink); font-size: 10px; font-weight: 400; line-height: 1.2; white-space: nowrap; }
#messageForm .composer-social-tools .communication-badge { top: 0; right: 1px; }
#messageForm .counter { margin-inline-start: auto; font-size: 11px; }

/* Public messages have an identity header and a separate compact bubble.
   Private/history messages keep their existing rendering and custom nicknames. */
#messageList { --message-text-size: 15px; gap: 6px; }
:root[data-message-size="small"] #messageList { --message-text-size: 14px; }
:root[data-message-size="large"] #messageList { --message-text-size: 18px; }
#messageList > .public-message-row { display: grid; grid-template-columns: 28px minmax(0, 1fr); column-gap: 9px; row-gap: 0; align-self: stretch; align-items: start; justify-items: stretch; width: 100%; max-width: 100%; margin: 0; padding: 0; border: 0; background: transparent; }
#messageList > .message-group-start:not(:first-child) { margin-top: 10px; }
#messageList > .public-message-row > .message-avatar { grid-column: 1; grid-row: 1; width: 28px; height: 28px; margin-top: 8px; border-radius: 9px; font-size: 12px; }
#messageList > .message-group-continuation > .message-avatar { visibility: hidden; }
#messageList > .public-message-row > .message-line { display: flex; flex-direction: column; grid-column: 2; gap: 4px; min-width: 0; width: 100%; padding: 0; border-radius: 0; background: transparent; }
#messageList .public-message-row .message-sender { display: flex; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 5px; min-height: 44px; margin: 0; line-height: 1.35; }
#messageList .public-message-row .message-sender .message-name { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; padding: 0; font-size: 13px; line-height: 1.35; }
#messageList .public-message-row .message-sender .member-rank-icon { display: inline-grid; flex: 0 0 17px; margin: 0 0 0 2px; vertical-align: middle; }
#messageList .public-message-row .message-colon { display: none; }
#messageList .public-message-row .message-bubble { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-width: 0; max-width: 100%; padding: 9px 12px; border-radius: 11px; background: var(--chat-incoming); }
#messageList .public-message-row.own .message-bubble { background: var(--chat-outgoing); }
#messageList .public-message-row .message-content { display: block; flex: 1 1 140px; min-width: 0; max-width: 100%; padding: 0; border: 0; border-radius: 0; color: var(--ink); background: transparent; font-size: var(--message-text-size); line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
#messageList .public-message-row .message-quote, #messageList .public-message-row .ai-sources { flex: 1 1 100%; width: 100%; margin: 0; }
#messageList .public-message-row .message-footer { display: flex; flex-direction: row; flex: 0 1 auto; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 6px 10px; min-width: 0; min-height: 24px; max-width: 100%; margin: 0 0 0 auto; }
#messageList .public-message-row .message-time { display: inline-block; flex: 0 0 auto; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
#messageList .public-message-row .message-footer:has(.message-reactions) { flex-basis: 100%; }
#messageList .public-message-row .message-reactions { order: -1; margin-inline-end: auto; gap: 4px; }
#messageList .public-message-row .message-reaction { min-width: 44px; min-height: 44px; padding: 5px 8px; font-size: 12px; }
#messageList .public-message-row.has-media .message-content:not(.sticker-message) { flex-basis: 100%; }
#messageList .public-message-row .message-content.sticker-message { display: flex; align-items: center; gap: 10px; padding: 0; font-size: 37px; line-height: 1.15; white-space: normal; }
#messageList .public-message-row .sticker-message > span { flex: 0 0 auto; }
#messageList .public-message-row .sticker-message small { min-width: 0; margin: 0; font-size: var(--message-text-size); line-height: 1.4; text-align: start; }

/* An inline actions tray cannot be clipped by the scroll viewport's edges. */
.message-overflow { position: relative; flex: 0 0 28px; width: 28px; height: 24px; }
.message-overflow-toggle { display: flex; align-items: center; justify-content: center; width: 44px; min-width: 44px; min-height: 44px; margin: -10px -8px; padding: 8px; border: 0; border-radius: 8px; color: var(--accent-text); background: transparent; font-size: 22px; line-height: 1; list-style: none; cursor: pointer; touch-action: manipulation; }
.message-overflow-toggle::-webkit-details-marker { display: none; }
.message-overflow-toggle::marker { content: ""; }
.message-overflow-toggle:hover, .message-overflow[open] > .message-overflow-toggle { background: var(--surface); }
.message-overflow-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: -3px; }
#messageList .message-footer:has(.message-overflow[open]) { flex-basis: 100%; }
.message-overflow[open] { flex: 1 1 100%; width: 100%; height: auto; }
.message-overflow[open] > .message-overflow-toggle { margin: 0 0 4px auto; }
.message-overflow-menu { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; width: 100%; padding: 6px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.message-overflow-menu .message-action-button { min-width: 44px; min-height: 44px; max-width: 100%; padding: 8px 10px; font-size: 13px; line-height: 1.3; }
.message-overflow-menu .message-action-button.remove-action { color: var(--error); font-size: 13px; }
.message-overflow-menu .reaction-choices { flex: 1 1 100%; gap: 3px; max-width: 100%; }
.message-overflow-menu .reaction-choices .message-action-button { flex: 0 0 44px; padding: 5px; font-size: 20px; }

@media (max-width: 760px) {
  body[data-view="chat"] > .app { padding: 0; }
  body[data-view="chat"] #chatView { border: 0; border-radius: 0; }
  #chatView .chat-header { min-height: 68px; gap: 8px; padding: 10px 12px; }
  #chatView .room-heading { gap: 8px; }
  #chatView .room-heading h1 { font-size: 19px; }
  #chatView .room-brand-mark { flex-basis: 28px; width: 28px; }
  #chatView .room-brand-mark svg { width: 28px; height: 28px; }
  #chatView .room-navigation { gap: 6px; }
  #chatView .room-navigation .leave-button { gap: 5px; padding-inline: 7px; }
  #chatView .message-scroll { padding: 12px 12px 18px; }
  #messageList { --message-text-size: 16px; }
  #messageForm { padding: 9px 12px max(6px, env(safe-area-inset-bottom)); }
  #messageForm > .composer-row { gap: 6px; }
  #messageForm #messageInput { padding-inline: 10px; }
}

/* Named rows reserve the composer even when a video section is present.
   Drawers end at the composer row, so Members/Friends cannot cover typing tools. */
@media (max-width: 680px), (orientation: landscape) and (max-height: 550px) and (max-width: 980px) {
  #chatView .lobby-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: [restriction] auto [connection] auto [video] auto [trivia] auto [activity] auto [messages] minmax(0, 1fr) [composer] auto [video-controls] auto [end]; }
  #chatView .conversation-column { display: contents; }
  #chatView .restriction-notice { grid-column: 1; grid-row: restriction; }
  #chatView .connection-notice { grid-column: 1; grid-row: connection; }
  #chatView .public-video { grid-column: 1; grid-row: video; }
  #chatView #roomTrivia { grid-column: 1; grid-row: trivia; }
  #chatView #aiActivity { grid-column: 1; grid-row: activity; }
  #chatView .conversation-frame { grid-column: 1; grid-row: messages; }
  #chatView #messageForm { grid-column: 1; grid-row: composer; }
  #chatView .pv-dock { grid-column: 1; grid-row: video-controls; }
  #chatView .lobby-layout > .chat-side-panel { grid-column: 1; grid-row: restriction / composer; justify-self: end; width: min(var(--side-panel-width), 100%); max-height: 100%; }
  #chatView:is([data-video-tab="users"], [data-video-tab="requests"]) .public-video.pv-expanded { grid-row: video / composer; }
}
@media (orientation: landscape) and (max-height: 550px) {
  :root[data-chat-viewport="true"] #chatView .public-video:not(.pv-expanded) { margin-top: 4px; }
}
@media (max-width: 359px) {
  #chatView .chat-header { flex-wrap: wrap; gap: 4px; padding: 8px 10px; }
  #chatView .room-heading { flex-basis: 100%; }
  #chatView .room-navigation { justify-content: flex-start; flex: 1 1 100%; margin-inline-start: 36px; }
  #chatView .message-scroll { padding-inline: 10px; }
  #messageForm { padding-inline: 10px; }
  #messageForm .composer-social-tools { gap: 0; }
  #messageList > .public-message-row { column-gap: 7px; }
  #messageList .public-message-row .message-bubble { padding-inline: 10px; }
  #messageList .public-message-row .message-content.sticker-message { flex-basis: 100%; }
}
@media (max-height: 500px) {
  #chatView .chat-header { padding-block: 6px; min-height: 58px; }
  #messageForm { padding-top: 6px; padding-bottom: max(4px, env(safe-area-inset-bottom)); }
  #messageForm #messageInput { max-height: 70px; }
  #messageForm .composer-footer { margin-top: 3px; }
}
