.auth-shell { min-height: 100dvh; display: grid; align-items: start; justify-items: center; padding: clamp(3rem, 10vh, 7rem) 1.35rem 2rem; }
.auth-card { width: min(100%, 410px); border: 1px solid color-mix(in srgb, var(--brand) 14%, var(--line)); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow-md); padding: clamp(1.5rem, 4vw, 2rem); }
.auth-logo { display: block; width: min(250px, 78%); height: auto; margin: 0 auto 1.35rem; }
.auth-heading { margin-bottom: .2rem; }
.auth-heading h1 { margin-bottom: .35rem; }
.auth-heading p, .stack-form p { margin-bottom: 0; color: var(--muted); line-height: 1.5; }
.stack-form { display: grid; gap: 1rem; }
.auth-card.login-card { width: min(100%, 340px); border: 0; border-radius: 0; background: transparent; box-shadow: none; padding: .5rem; }
.auth-card.login-card .auth-heading, .auth-card.login-card .version-label, .auth-card.login-card .password-toggle { display: none; }
.auth-card.login-card .stack-form { gap: .72rem; }
.login-field { position: relative; display: block; }
.login-field > svg { position: absolute; top: 50%; left: .95rem; z-index: 2; width: 21px; height: 21px; transform: translateY(-50%); fill: none; stroke: var(--icon); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.auth-card.login-card input { min-height: 50px; border-radius: 14px; background: var(--surface); padding: .72rem 1rem .72rem 3rem; font-size: 1rem; box-shadow: 0 1px 2px rgba(11, 20, 26, .04); }
.auth-card.login-card .login-submit { justify-self: end; width: 50px; min-width: 50px; height: 50px; min-height: 50px; border-radius: 50%; padding: 0; box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 22%, transparent); }
.login-submit svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.login-submit[aria-busy="true"]::before { content: ""; width: 19px; height: 19px; border: 2px solid color-mix(in srgb, currentColor 36%, transparent); border-top-color: currentColor; border-radius: 50%; animation: login-spin .7s linear infinite; }
@keyframes login-spin { to { transform: rotate(360deg); } }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 5rem; }
.password-toggle { position: absolute; top: 50%; right: .4rem; transform: translateY(-50%); border: 0; border-radius: 8px; background: transparent; color: var(--brand); padding: .4rem .52rem; font-size: .78rem; }
.form-message { border: 1px solid color-mix(in srgb, var(--danger) 38%, var(--line)); border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); padding: .72rem .8rem; line-height: 1.4; }
.form-message.success { border-color: color-mix(in srgb, var(--success) 38%, var(--line)); background: var(--success-soft); color: var(--success); }

.button { display: inline-flex; align-items: center; justify-content: center; gap: .42rem; min-height: 40px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--text); padding: .52rem .82rem; text-decoration: none; transition: transform .15s ease, border-color .15s ease, background .15s ease; }
.button:hover { border-color: var(--brand); background: var(--surface-hover); }
.button:active { transform: translateY(1px); }
.button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.button.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
:root[data-theme="dark"] .button.primary { color: #0d1729; }
.button.ghost { background: transparent; }
.button.subtle { background: var(--surface-muted); }
.button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); background: var(--danger-soft); }
.button.full { width: 100%; }
.button.compact { min-height: 34px; border-radius: 9px; padding: .38rem .62rem; font-size: .78rem; }
.icon-button { width: 44px; min-width: 44px; padding: 0; font-size: 1.28rem; }
.notice { border-radius: var(--radius); padding: 1rem; background: var(--surface-muted); border: 1px solid var(--line); line-height: 1.55; }
.notice-error { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); background: var(--danger-soft); }
.empty-state { display: grid; justify-items: center; gap: .45rem; padding: 2.5rem 1rem; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--text); }
.version-label { color: var(--muted); font-size: .76rem; text-align: center; margin: 1.35rem 0 0; }
.version-chip { align-self: flex-start; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); padding: .28rem .56rem; font-size: .72rem; }
.eyebrow { margin-bottom: .28rem; color: var(--brand); font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

.app-shell { width: min(calc(100% - 28px), var(--content)); height: calc(100dvh - 28px); min-height: 0; margin: 14px auto; display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; border: 1px solid color-mix(in srgb, var(--brand) 10%, var(--line-strong)); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow-md); }
.app-shell.room-active { height: calc(100dvh - 28px); }
.topbar { position: relative; top: auto; z-index: 30; min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .5rem .75rem; border-bottom: 1px solid var(--line-strong); background: color-mix(in srgb, var(--surface-muted) 92%, transparent); backdrop-filter: blur(18px); }
.topbar-leading, .topbar-actions, .room-quick-actions { display: flex; align-items: center; gap: .42rem; min-width: 0; }
.selection-topbar { width: 100%; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.selection-topbar-leading, .selection-topbar-actions { display: flex; align-items: center; min-width: 0; }
.selection-topbar-leading { gap: .38rem; }
.selection-topbar-actions { gap: .08rem; }
.selection-topbar-leading strong { min-width: 28px; font-size: 1.05rem; }
.selection-topbar-action { width: 42px; min-width: 42px; height: 42px; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--icon); padding: 0; }
.selection-topbar-action:hover { background: var(--surface-hover); color: var(--brand); }
.selection-topbar-action.danger-action { color: var(--danger); }
.selection-topbar-action.danger-action:hover { background: var(--danger-soft); color: var(--danger); }
.selection-topbar-action svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.topbar-back { font-size: 1.25rem; }
.brand-line { display: flex; align-items: center; gap: .62rem; min-width: 0; }
.brand-line img { flex: 0 0 auto; width: 32px; height: 32px; }
.contact-avatar { position: relative; flex: 0 0 auto; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(145deg, var(--brand), var(--brand-strong)); color: #fff; box-shadow: 0 2px 8px color-mix(in srgb, var(--brand) 30%, transparent); font-size: .76rem; font-weight: 800; letter-spacing: .03em; }
.contact-avatar.online::after { content: ""; position: absolute; right: 0; bottom: 1px; width: 9px; height: 9px; border: 2px solid var(--surface-muted); border-radius: 50%; background: var(--brand); }
.brand-line div { display: grid; min-width: 0; }
.brand-line strong, .brand-line span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-line strong { font-size: 1rem; }
.brand-line span { color: var(--muted); font-size: .8125rem; }
.app-shell.room-active #accountMenu { display: none; }
.app-shell.room-active .brand-line > img { display: none; }
.room-quick-actions { gap: .18rem; }
.topbar-quick-action { width: 40px; min-width: 40px; min-height: 40px; border-color: transparent; background: transparent; color: var(--icon); }
.topbar-quick-action:hover { border-color: transparent; background: var(--surface-hover); }
.topbar-quick-action.danger-action:hover { color: var(--danger); background: var(--danger-soft); }
.topbar-quick-action svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-icon-sun { display: block; }
.account-menu { position: relative; flex: 0 0 auto; }
.account-menu summary { list-style: none; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-trigger { min-height: 38px; padding: .24rem .5rem .24rem .3rem; background: transparent; border-color: transparent; }
.account-avatar { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 50%; background: var(--brand); color: white; font-size: .72rem; font-weight: 800; }
.account-popover { position: absolute; top: calc(100% + .55rem); right: 0; z-index: 50; width: min(286px, calc(100vw - 1rem)); display: grid; gap: .25rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-md); padding: .55rem; }
.account-summary { display: grid; padding: .55rem .6rem .72rem; border-bottom: 1px solid var(--line); margin-bottom: .15rem; }
.account-summary small { color: var(--muted); }
.menu-action { display: flex; align-items: center; gap: .65rem; width: 100%; min-height: 42px; border: 0; border-radius: 9px; background: transparent; color: var(--text); padding: .55rem .65rem; font-size: .875rem; text-align: left; }
.menu-action:hover, .menu-action.selected { background: var(--surface-hover); }
.menu-action.selected { color: var(--brand); font-weight: 700; }
.theme-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: .25rem; border-bottom: 1px solid var(--line); padding-bottom: .4rem; }
.theme-choices .menu-action { justify-content: center; padding-inline: .3rem; font-size: .78rem; }
.danger-text { color: var(--danger); }

.view { width: 100%; min-height: 0; margin: 0; padding: .9rem 1rem 1rem; overflow: auto; }
.view-heading, .room-toolbar, .admin-toolbar, .editor-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.dashboard-actions, .admin-direct-actions { display: flex; align-items: center; gap: .4rem; }
.view-heading { width: min(100%, 720px); margin: 0 auto; min-height: 38px; }
.view-heading h1 { margin: 0; color: var(--muted); font-size: .76rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.view-heading p:not(.eyebrow) { display: none; }
.room-grid { width: min(100%, 720px); display: flex; flex-direction: column; gap: 0; margin: .35rem auto 0; }
.room-card { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: .8rem; min-height: 74px; padding: .58rem .5rem; border: 0; border-bottom: 1px solid var(--line); border-radius: 12px; background: transparent; box-shadow: none; text-align: left; color: var(--text); transition: background .15s ease; }
.room-card:hover { transform: none; border-color: var(--line); background: var(--surface-hover); box-shadow: none; }
.room-card:active { background: var(--surface-muted); }
.room-avatar { position: relative; display: grid; place-items: center; width: 50px; height: 50px; border: 1px solid color-mix(in srgb, var(--brand) 12%, var(--line)); border-radius: 50%; background: linear-gradient(145deg, var(--surface-muted), color-mix(in srgb, var(--brand) 9%, var(--surface))); color: var(--brand-strong); font-weight: 800; letter-spacing: .03em; }
.room-avatar.online::after { content: ""; position: absolute; right: 0; bottom: 2px; width: 10px; height: 10px; border: 2px solid var(--surface); border-radius: 50%; background: var(--brand); }
.room-card-content { display: grid; min-width: 0; gap: .2rem; }
.room-card-heading, .room-card-meta { display: flex; align-items: center; justify-content: space-between; gap: .55rem; min-width: 0; }
.room-card-heading strong { overflow: hidden; font-size: 1rem; text-overflow: ellipsis; white-space: nowrap; }
.room-card-heading time { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.room-preview { display: block; overflow: hidden; color: var(--muted); font-size: .84rem; text-overflow: ellipsis; white-space: nowrap; padding-right: 4.5rem; }
.room-card-meta { position: absolute; right: .5rem; bottom: .7rem; justify-content: flex-end; flex-wrap: nowrap; color: var(--muted); font-size: .72rem; }
.room-card-meta > span:not(.unread-badge) { display: none; }
.room-card-meta .online-text { display: inline-flex; color: var(--brand-strong); }
.room-card-meta > span:not(:last-child)::after { content: "·"; margin-left: .45rem; color: var(--line-strong); }
.unread-badge { margin-left: auto; min-width: 22px; border-radius: 999px; padding: .14rem .4rem; background: var(--brand); color: white; font-size: .68rem; font-weight: 800; text-align: center; }
.room-card-meta .unread-badge::after { content: none; }

.room-view { --room-inline-pad: .72rem; --room-inline-offset: -.72rem; --room-footer-extra: 1.44rem; position: relative; min-width: 0; min-height: 0; display: grid; grid-template-rows: max-content minmax(0, 1fr) max-content; height: 100%; padding: .35rem var(--room-inline-pad) 0; background-color: var(--chat-bg); background-image: radial-gradient(circle at 18px 18px, color-mix(in srgb, var(--icon) 5%, transparent) 1.2px, transparent 1.3px), radial-gradient(circle at 58px 52px, color-mix(in srgb, var(--icon) 4%, transparent) 1px, transparent 1.1px); background-size: 76px 76px; overflow: hidden; }
.room-toolbar { grid-row: 1; min-height: 36px; justify-content: center; }
.room-toolbar:has(#loadOlderButton[hidden]) { display: none; }
.room-toolbar .button { min-height: 34px; padding: .35rem .65rem; color: var(--muted); font-size: .75rem; }
.message-list { grid-row: 2; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; padding: .22rem .24rem .52rem; scroll-behavior: auto; overflow-anchor: none; }
.room-view.room-loading::after { content: "Carregando conversa…"; position: absolute; inset: 50% auto auto 50%; z-index: 18; transform: translate(-50%, -50%); border: 1px solid var(--line); border-radius: 999px; background: color-mix(in srgb, var(--surface) 95%, transparent); color: var(--muted); box-shadow: var(--shadow-sm); padding: .45rem .75rem; font-size: .78rem; }
.room-view.room-loading .message-list { visibility: hidden; }
.message-list > .empty-state { min-height: 100%; align-content: center; }
.date-separator, .unread-separator { width: max-content; max-width: 90%; margin: .48rem auto .62rem; border: 1px solid var(--line); border-radius: 999px; background: color-mix(in srgb, var(--surface) 94%, transparent); color: var(--muted); padding: .22rem .58rem; font-size: .6875rem; box-shadow: var(--shadow-sm); }
.unread-separator { border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); background: var(--brand-soft); color: var(--brand-text); font-weight: 700; }
.message { position: relative; width: min(74%, 640px); margin: .08rem auto .08rem 0; display: flex; justify-content: flex-start; }
.message.mine { margin-left: auto; margin-right: 0; justify-content: flex-end; }
.message-bubble { position: relative; min-width: 72px; max-width: 100%; border: 0; border-radius: 9px 9px 9px 3px; background: var(--bubble-other); padding: .32rem .46rem .25rem; box-shadow: var(--shadow-sm); }
.message-bubble:has(> .message-menu) { padding-right: 1.9rem; }
.message.mine .message-bubble { border-radius: 10px 10px 3px 10px; background: var(--bubble-own); border: 0; }
.message.selected .message-bubble, .media-tile.selected { outline: 2px solid color-mix(in srgb, var(--brand) 46%, transparent); }
.message.pending { opacity: .78; }
.message.failed .message-bubble { border-color: var(--danger); }
.message-highlight .message-bubble { animation: message-highlight 1.8s ease; }
@keyframes message-highlight { 0%, 100% { box-shadow: var(--shadow-sm); } 35% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--brand) 30%, transparent); } }
.message-head { min-height: 0; color: var(--muted); font-size: .72rem; padding-right: 1.45rem; }
.app-shell.room-active .message-head { display: none; }
.message-head strong { color: var(--brand-strong); }
.message-body { display: inline; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .875rem; line-height: 1.32; }
.message-body.emoji-one, .message-body.emoji-few, .message-body.sticker-only { line-height: 1; }
.message-body.emoji-one { font-size: 3rem; }
.message-body.emoji-few { font-size: 2.15rem; letter-spacing: .08em; }
.message-body.sticker-only { background: transparent; }
.message-link { color: var(--brand); text-decoration: underline; text-decoration-thickness: 1px; overflow-wrap: anywhere; }
.inline-mascot { display: inline-block; width: 1.65em; height: 1.65em; object-fit: contain; vertical-align: -.42em; }
.message-sticker { display: block; width: min(230px, 65vw); max-height: 230px; object-fit: contain; }
.reply-preview { width: 100%; display: grid; gap: .12rem; margin: .1rem 0 .42rem; border: 0; border-left: 3px solid var(--brand); border-radius: 7px; background: color-mix(in srgb, var(--surface-muted) 85%, transparent); color: var(--muted); padding: .4rem .52rem; text-align: left; }
.reply-preview strong { color: var(--brand); font-size: .72rem; }
.reply-preview span { overflow: hidden; font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
.reply-preview.static { cursor: default; }
.message-foot { display: inline-flex; align-items: center; justify-content: flex-end; gap: .18rem; min-height: 15px; margin: 0 0 0 .38rem; color: var(--muted); font-size: .64rem; vertical-align: -.12rem; white-space: nowrap; }
.receipt { display: inline-grid; place-items: center; width: 21px; height: 17px; flex: 0 0 auto; border: 0; border-radius: 999px; background: transparent; color: color-mix(in srgb, var(--muted) 92%, transparent); padding: 0; line-height: 1; cursor: help; transition: color .18s ease, transform .18s ease, background .18s ease; }
button.receipt:hover, button.receipt:focus-visible { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); outline: none; }
.receipt svg { display: block; overflow: visible; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.receipt-sent { width: 17px; }
.receipt-delivered { color: color-mix(in srgb, var(--muted) 96%, transparent); }
.receipt-read { color: #53bdeb; }
.receipt-sending svg { animation: receipt-clock 1.15s linear infinite; }
.receipt-failed { color: var(--danger); cursor: default; }
.receipt-dot { fill: currentColor; stroke: none; }
@keyframes receipt-clock { to { transform: rotate(360deg); transform-origin: center; } }
@media (prefers-reduced-motion: reduce) { .receipt-sending svg { animation: none; } }
.retry-message, .retry-upload { border: 0; background: transparent; color: var(--danger); padding: 0; text-decoration: underline; font-size: .68rem; }
.message-menu { position: absolute; top: .12rem; right: .15rem; z-index: 8; }
.message-bubble > .message-menu { top: .12rem; right: .15rem; }
.message.mine .message-bubble > .message-menu { left: auto; right: .15rem; }
.message-menu summary { display: grid; place-items: center; width: 26px; height: 26px; list-style: none; border-radius: 8px; color: var(--muted); cursor: pointer; opacity: 0; transform: translateY(-2px); transition: opacity .14s ease, transform .14s ease, background .14s ease; font-size: .78rem; line-height: 1; letter-spacing: .04em; }
.message-menu summary::-webkit-details-marker { display: none; }
.message-menu summary:hover { background: var(--surface-hover); color: var(--text); }
.message:hover .message-menu summary, .message-menu[open] summary, .message-menu summary:focus-visible { opacity: 1; transform: none; }
.message-menu-panel { position: absolute; top: 30px; right: 0; width: min(260px, calc(100vw - 1rem)); display: grid; gap: .3rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-md); padding: .4rem; }
.message.mine .message-bubble > .message-menu .message-menu-panel { left: auto; right: 0; }
.message-menu-actions { display: flex; align-items: center; justify-content: space-evenly; flex-wrap: nowrap; gap: .15rem; }
.message-action { position: relative; width: 40px; min-width: 40px; height: 40px; min-height: 40px; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--icon); padding: 0; }
.message-action:hover { background: var(--surface-hover); color: var(--brand); }
.message-action.danger { color: var(--danger); }
.message-action.danger:hover { background: var(--danger-soft); color: var(--danger); }
.message-action svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.reaction-picker { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .14rem; }
.reaction-picker.quick { padding-bottom: .28rem; border-bottom: 1px solid var(--line); }
.reaction-picker.expanded { max-height: 138px; overflow-y: auto; padding-top: .12rem; }
.reaction-choice { display: grid; place-items: center; min-width: 0; min-height: 32px; border: 0; border-radius: 8px; background: transparent; padding: 0; font-size: 1rem; }
.reaction-choice:hover, .reaction-choice.selected { background: var(--brand-soft); }
.reaction-more { color: var(--icon); }
.reaction-more[aria-expanded="true"] { background: var(--brand-soft); color: var(--brand); }
.reaction-more svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.reaction-mascot { width: 25px; height: 25px; object-fit: contain; }
.reaction-line { display: flex; flex-wrap: wrap; gap: .25rem; min-height: 0; margin-top: .12rem; }
.reaction-line:empty { display: none; }
.reaction-pill { display: inline-flex; align-items: center; gap: .1rem; min-height: 26px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); padding: .1rem .4rem; font-size: .72rem; }
.reaction-pill.mine { border-color: var(--brand); background: var(--brand-soft); }
.message-list.selection-active { padding-inline: .24rem; }
.message-list.selection-active .message { width: 100%; min-height: 34px; align-items: center; padding: .12rem .2rem .12rem 2.45rem; border-radius: 8px; }
.message-list.selection-active .message.selected { background: color-mix(in srgb, var(--brand) 13%, transparent); }
.message-list.selection-active .message .message-bubble { max-width: min(88%, 640px); }
.selection-check, .message.mine .selection-check { position: absolute; top: 50%; left: .42rem; right: auto; transform: translateY(-50%); width: 28px; height: 28px; display: grid; place-items: center; border: 2px solid var(--line-strong); border-radius: 50%; background: var(--surface); color: white; z-index: 4; }
.selection-check.selected { border-color: var(--brand); background: var(--brand); }
.media-message { width: min(86%, 760px); }
.media-bubble { width: fit-content; max-width: 100%; }
.media-gallery { --media-thumb-size: 104px; display: grid; grid-template-columns: repeat(3, var(--media-thumb-size)); gap: 3px; width: fit-content; max-width: 100%; }
.media-gallery.count-1 { grid-template-columns: var(--media-thumb-size); }
.media-gallery.count-2 { grid-template-columns: repeat(2, var(--media-thumb-size)); }
.media-tile { position: relative; width: var(--media-thumb-size); aspect-ratio: 1; min-width: 0; border-radius: 9px; background: #111722; }
.protected-media { position: relative; width: 100%; height: 100%; display: grid; place-items: center; overflow: hidden; border: 0; border-radius: inherit; background: #111722; color: white; padding: 0; }
.protected-media img { position: absolute; inset: -8px; width: calc(100% + 16px); height: calc(100% + 16px); object-fit: cover; filter: blur(9px) brightness(.58); transform: scale(1.04); }
.media-placeholder { font-size: 2rem; opacity: .7; }
.media-lock { position: relative; z-index: 1; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: rgba(0,0,0,.52); font-size: .82rem; }
.media-tile .message-menu { top: .2rem; right: .2rem; }
.media-tile .message-menu summary { background: rgba(0,0,0,.42); color: white; }
.media-tile .message-menu-panel { top: 30px; }
.media-tile .selection-check { left: .3rem; top: .3rem; transform: none; width: 25px; height: 25px; background: rgba(7,10,16,.76); }
.media-tile .selection-check.selected { background: var(--brand); }
.media-tile .reaction-line { position: absolute; left: .25rem; bottom: .25rem; z-index: 2; max-width: calc(100% - .5rem); }
.media-tile .reaction-pill { min-height: 22px; padding: .05rem .28rem; font-size: .65rem; }

.scroll-latest { position: absolute; left: 50%; bottom: calc(var(--room-footer-height, 55px) + .4rem); z-index: 20; width: max-content; max-width: min(220px, calc(100% - 1.5rem)); min-height: 34px; transform: translateX(-50%); border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); padding: .35rem .68rem; font-size: .78rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-footer { position: relative; grid-row: 3; z-index: 25; min-width: 0; width: calc(100% + var(--room-footer-extra)); margin: 0 var(--room-inline-offset); background: var(--surface-muted); border-top: 1px solid var(--line-strong); box-shadow: 0 -3px 12px color-mix(in srgb, var(--text) 5%, transparent); }
.typing-status { min-height: 19px; color: var(--muted); font-size: .75rem; padding: .08rem calc(var(--room-inline-pad) + .2rem); }
.typing-status:empty { display: none; }
.reply-strip { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-left: 4px solid var(--brand); background: var(--surface-muted); padding: .55rem .7rem; }
.reply-strip div { display: grid; min-width: 0; gap: .15rem; }
.reply-strip strong { font-size: .75rem; color: var(--brand); }
.reply-strip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .8rem; }
.reply-strip button { flex: 0 0 auto; border: 0; background: transparent; color: var(--muted); font-size: 1.35rem; }
.edit-strip { border-left-color: var(--warning); }
.composer { position: relative; z-index: 1; min-width: 0; width: 100%; display: flex; align-items: flex-end; gap: .32rem; margin: 0; padding: .42rem max(.5rem, env(safe-area-inset-right)) max(.42rem, env(safe-area-inset-bottom)) max(.5rem, env(safe-area-inset-left)); background: var(--surface-muted); overflow: visible; }
.composer-field { flex: 1 1 auto; min-width: 0; border: 1px solid var(--line); border-radius: 21px; background: var(--surface); overflow: hidden; }
.composer-field:focus-within { border-color: var(--brand); box-shadow: var(--focus); }
.composer textarea { display: block; width: 100%; height: 40px; min-height: 40px; max-height: 96px; border: 0; border-radius: 0; box-shadow: none; padding: .6rem .76rem .46rem; overflow-x: hidden; overflow-y: auto; font-size: .875rem; line-height: 1.28; overflow-wrap: normal; word-break: normal; }
.composer textarea:focus-visible { border: 0; box-shadow: none; }
.composer-meta { min-height: 17px; display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: 0 .72rem .25rem; color: var(--muted); font-size: .65rem; }
.composer-meta:not(:has(#uploadStatus:not(:empty), #messageCounter:not(:empty), #retryUploadsButton:not([hidden]))) { display: none; }
.composer-media, .composer-emoji, .composer-send { flex: 0 0 auto; display: grid; place-items: center; margin: 0; line-height: 0; }
.composer-media, .composer-emoji { width: 38px; min-width: 38px; max-width: 38px; height: 40px; min-height: 40px; max-height: 40px; padding: 0; border-color: transparent; background: transparent; color: var(--icon); }
.composer-media:hover, .composer-emoji:hover { border-color: transparent; background: var(--surface-hover); }
.composer-media svg, .composer-emoji svg, .composer-send svg { display: block; flex: none; fill: none; stroke: currentColor; stroke-width: 1.85; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.composer-media svg { width: 22px; height: 22px; }
.composer-emoji svg { width: 24px; height: 24px; }
.composer-send { width: 42px; min-width: 42px; max-width: 42px; height: 42px; min-height: 42px; max-height: 42px; padding: 0; border-radius: 50%; }
.composer-send svg { width: 21px; height: 21px; transform: translateX(1px); stroke-width: 1.9; }
.emoji-picker { position: absolute; left: 3rem; bottom: calc(100% + .45rem); z-index: 20; width: min(360px, calc(100vw - 1.3rem)); max-height: 390px; overflow-y: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-md); padding: .65rem; }
.picker-title { display: block; margin: .25rem 0 .45rem; font-size: .75rem; color: var(--muted); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: .22rem; }
.emoji-grid button, .sticker-grid button { min-width: 0; border: 0; border-radius: 8px; background: transparent; }
.emoji-grid button { aspect-ratio: 1; font-size: 1.25rem; }
.emoji-grid button:hover, .sticker-grid button:hover { background: var(--surface-hover); }
.sticker-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: .3rem; }
.sticker-grid img { display: block; width: 100%; height: 52px; object-fit: contain; }

.modal { width: min(900px, calc(100% - 1.2rem)); height: min(780px, calc(100dvh - 1.2rem)); padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-md); }
.modal::backdrop, .media-viewer::backdrop { background: rgba(5, 10, 20, .72); backdrop-filter: blur(4px); }
.modal-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .85rem 1rem; border-bottom: 1px solid var(--line); background: var(--surface); }
.modal-header h2 { margin: 0; }
.admin-modal { grid-template-rows: auto auto minmax(0, 1fr); }
.admin-modal[open] { display: grid; }
.admin-tabs { display: flex; gap: .25rem; padding: .55rem .75rem 0; border-bottom: 1px solid var(--line); }
.admin-tab { min-height: 42px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); padding: .5rem .8rem; }
.admin-tab.active { border-bottom-color: var(--brand); color: var(--brand); font-weight: 700; }
.admin-content { min-height: 0; overflow: auto; padding: .85rem; }
.admin-toolbar { position: sticky; top: 0; z-index: 2; padding-bottom: .75rem; background: var(--surface); }
.search-field { flex: 1 1 auto; }
.admin-list { display: grid; gap: .55rem; }
.admin-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .8rem; padding: .78rem; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-muted); }
.admin-item-main { min-width: 0; }
.admin-item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-item small { display: block; margin-top: .16rem; color: var(--muted); }
.status-chip { display: inline-flex; align-items: center; border-radius: 999px; background: var(--success-soft); color: var(--success); padding: .16rem .42rem; font-size: .68rem; font-weight: 700; }
.status-chip.inactive { background: var(--danger-soft); color: var(--danger); }
.admin-editor { display: grid; gap: .8rem; }
.editor-heading { border-bottom: 1px solid var(--line); padding-bottom: .7rem; }
.editor-heading h3 { margin: 0; font-size: 1.35rem; }
.editor-card { display: grid; gap: .8rem; padding: .85rem; }
.editor-card fieldset { margin: 0; border: 1px solid var(--line); border-radius: 12px; padding: .75rem; }
.editor-card legend { padding: 0 .3rem; color: var(--text); font-weight: 700; }
.direct-pair-card { display: grid; gap: .8rem; border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--line)); border-radius: 16px; background: color-mix(in srgb, var(--brand-soft) 34%, var(--surface)); padding: .9rem; }
.direct-pair-heading { display: flex; align-items: center; gap: .65rem; }
.direct-pair-heading > span { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto; border-radius: 50%; background: var(--brand); color: #fff; font-size: 1.1rem; font-weight: 800; }
.direct-pair-heading div { display: grid; gap: .14rem; }
.direct-pair-heading small { color: var(--muted); line-height: 1.35; }
.direct-pair-fields { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.check-line { display: flex; align-items: center; gap: .48rem; color: var(--text); }
.check-line input { width: auto; margin: 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; padding-top: .25rem; }
.ttl-modal { width: min(390px, calc(100% - 1.2rem)); height: auto; max-height: calc(100dvh - 1.2rem); margin: auto; }
.ttl-modal[open] { display: block; }
.quick-dialog { height: fit-content; max-height: calc(100dvh - 1.2rem); padding: 0; overflow: hidden; }
.quick-dialog-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .55rem; padding: .72rem .72rem .62rem .9rem; border-bottom: 1px solid var(--line); text-align: center; }
.quick-dialog-header h2 { margin: 0; padding-left: 36px; font-size: 1.02rem; }
.quick-dialog-header .icon-button { width: 36px; min-width: 36px; min-height: 36px; padding: 0; }
.ttl-choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .38rem; padding: .58rem; max-height: min(430px, 70dvh); overflow-y: auto; }
.ttl-choice { min-height: 43px; border: 1px solid var(--line); border-radius: 10px; padding: .45rem .5rem; background: var(--surface); color: var(--text); text-align: center; font-size: .82rem; font-weight: 700; }
.ttl-choice:hover, .ttl-choice:focus-visible { border-color: var(--brand); background: var(--brand-soft); }
.ttl-choice.selected { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 -3px var(--brand); }
.confirm-modal { width: min(330px, calc(100% - 1.2rem)); height: fit-content; margin: auto; }
.confirm-modal[open] { display: block; }
.confirm-dialog-actions { display: grid; grid-template-columns: .78fr 1.35fr; gap: .5rem; width: 100%; padding: .68rem; }
.confirm-dialog-actions .button { min-height: 42px; padding: .52rem .65rem; }

.media-viewer { max-width: min(1100px, 96vw); max-height: 94dvh; border: 0; border-radius: 16px; padding: 2.4rem 1rem 1rem; background: #06090f; }
.media-viewer img, .media-viewer video { display: block; max-width: 92vw; max-height: 86dvh; margin: auto; }
.viewer-close { position: absolute; top: .4rem; right: .55rem; border: 0; background: transparent; color: white; font-size: 2rem; }
.viewer-status { color: white; text-align: center; }
.toast { position: fixed; left: 50%; bottom: max(1rem, env(safe-area-inset-bottom)); z-index: 100; transform: translate(-50%, 150%); width: max-content; max-width: calc(100% - 2rem); border-radius: 999px; background: var(--text); color: var(--surface); padding: .72rem 1rem; opacity: 0; box-shadow: var(--shadow-md); transition: .2s ease; text-align: center; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
