:root {
    color-scheme: light;
    --bg: #eef2f0;
    --panel: #ffffff;
    --panel-soft: #f7faf8;
    --text: #13231b;
    --muted: #66756d;
    --line: #d9e1dc;
    --brand: #146c43;
    --brand-dark: #0e4b31;
    --accent: #2563eb;
    --danger: #b42318;
    --shadow: 0 12px 32px rgba(19, 35, 27, .10);
    --sidebar-width: 380px;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

html.admin-html,
html.admin-html body.admin-page {
    height: auto !important;
    min-height: 100%;
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
}

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 8px minmax(0, 1fr);
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

.sidebar,
.chat {
    min-width: 0;
    min-height: 0;
    background: var(--panel);
}

.sidebar {
    display: flex;
    flex-direction: column;
}

.layout-resizer {
    position: relative;
    cursor: col-resize;
    background: transparent;
    border-left: 1px solid var(--line);
    border-right: 1px solid transparent;
    touch-action: none;
}

.layout-resizer::before {
    content: "";
    position: absolute;
    inset: 0 3px;
    border-radius: 4px;
    background: transparent;
}

.layout-resizer:hover::before,
.layout-resizer.active::before {
    background: #b8d8c5;
}

body.resizing-layout {
    cursor: col-resize;
    user-select: none;
}

.topbar,
.chat-header {
    min-height: 76px;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--line);
}

.topbar {
    display: block;
    align-items: stretch;
    justify-content: stretch;
    min-height: 133px;
    height: auto;
    padding: 12px;
}

.topbar > div {
    min-width: 0;
}

.topbar-main {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
}

.topbar-row {
    display: grid;
    grid-template-columns: minmax(70px, .9fr) minmax(96px, 1fr) 30px 30px;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-width: 0;
}

.topbar-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-width: 0;
}

.sidebar-filter-row {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
}

.sidebar-tools-row {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    gap: 8px;
    padding-top: 2px;
}

.activity-tool-button {
    min-height: 32px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel-soft);
    color: var(--text);
    font-size: 13px;
    font-weight: 800;
}

.activity-tool-button.active,
.activity-tool-button:hover {
    background: #e4f3ea;
    border-color: #b8d8c5;
    color: var(--brand-dark);
}

.tech-status {
    display: flex;
    align-items: center;
    margin-top: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.25;
    white-space: nowrap;
}

.tech-state {
    color: var(--brand);
    font-weight: 700;
}

.tech-manager {
    color: var(--text);
    font-weight: 800;
}

.tech-manager::after {
    content: " · ";
    color: var(--muted);
    font-weight: 500;
}

.tech-state.offline {
    color: var(--danger);
    font-weight: 800;
}

.group-picker {
    display: flex;
    align-items: center;
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
    min-width: 0;
    min-width: 0;
}

.group-picker select {
    width: 100%;
    min-width: 0;
    max-width: none;
    height: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--text);
    font: inherit;
    padding: 0 6px;
}

.manager-filter {
    display: block;
    width: 100%;
    padding: 0;
    min-width: 0;
}

.manager-filter select {
    width: 100%;
    height: 32px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--text);
    padding: 0 8px;
    min-width: 0;
}

.tag-filter select {
    width: 100%;
    height: 32px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--text);
    padding: 0 8px;
    min-width: 0;
}

.logout-link,
.admin-icon-link {
    width: 30px;
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    padding: 0;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel-soft);
    color: var(--muted);
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
}

.admin-icon-link:hover {
    background: #e9f5ef;
    border-color: #b8d8c5;
    color: var(--brand-dark);
}

.logout-link:hover {
    background: #f7e6e6;
    border-color: #efc4c4;
    color: #9f1d1d;
}

.kicker,
.chat-title p,
.chat-identity p,
.status-line {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.app-title {
    margin: 0;
}

.app-title a {
    color: inherit;
    text-decoration: none;
}

.app-title a:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.title-refresh {
    width: 100%;
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    min-width: 0;
    padding: 0 9px;
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--text);
    border: 1px solid var(--line);
    font-weight: 800;
    font-size: 14px;
    line-height: 1.15;
}

.title-refresh span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.title-refresh:hover {
    background: #e4f3ea;
    border-color: #b8d8c5;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(180deg, #f8fbf9, #eef4f1);
}

.auth-card {
    width: min(320px, 100%);
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    box-shadow: none;
}

.auth-card h1 {
    margin: 0 0 18px;
    font-size: 22px;
}

.auth-card form {
    display: grid;
    gap: 8px;
}

.auth-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 46px;
    gap: 8px;
}

.auth-totp-card .auth-row {
    grid-template-columns: minmax(0, 1fr);
}

.auth-card input,
.auth-card select {
    width: 100%;
    height: 46px;
    border-radius: 8px;
    border: 1px solid var(--line);
    padding: 0 14px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.auth-card input:focus,
.auth-card select:focus {
    outline: 0;
    border-color: #b8d8c5;
    box-shadow: 0 0 0 3px rgba(20, 108, 67, .14), var(--shadow);
}

.auth-card button {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    font-size: 24px;
    font-weight: 800;
    line-height: 1;
}

.auth-card button:hover {
    background: var(--brand-dark);
}

.auth-manager-card {
    width: min(420px, 100%);
}

.auth-manager-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.auth-manager-list button {
    width: 100%;
    min-height: 46px;
    padding: 0 12px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    font-size: 15px;
}

.auth-manager-list button:hover {
    background: #e4f3ea;
    border-color: #b8d8c5;
    color: var(--brand-dark);
}

.auth-error {
    margin: 0;
    color: var(--danger);
    font-size: 13px;
    font-weight: 700;
}

.auth-submit-state {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
    text-align: center;
}

.online-name {
    color: var(--brand);
}

h1,
h2,
h3 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: 24px;
    line-height: 1.1;
}

h2 {
    font-size: 19px;
    line-height: 1.2;
}

h3 {
    font-size: 20px;
}

.icon-button,
.icon-secondary,
.back-button,
.attach-button {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--panel-soft);
    color: var(--brand-dark);
    border: 1px solid var(--line);
    font-weight: 700;
}

.toolbar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    padding: 10px 12px 8px;
}

.notification-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    padding: 0 12px 8px;
}

.topbar-status-row .notification-actions {
    display: inline-flex;
    grid-template-columns: none;
    align-items: center;
    flex: 0 0 auto;
    gap: 4px;
    padding: 0;
}

.topbar-status-row .notification-actions .secondary {
    min-height: 28px;
    height: 28px;
    padding: 0 8px;
    font-size: 12px;
    line-height: 1;
}

.topbar-status-row .notification-actions .icon-notify {
    width: 30px;
    padding: 0;
}

.notify-scope-toggle {
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex: 0 0 auto;
    padding: 0 7px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.notify-scope-toggle input {
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: var(--brand);
}

.segment,
.secondary {
    min-height: 34px;
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--text);
    border: 1px solid var(--line);
    padding: 0 10px;
    font-size: 13px;
}

.segment.active,
.secondary:hover,
.icon-secondary:hover,
.icon-button:hover,
.back-button:hover {
    background: #e4f3ea;
    border-color: #b8d8c5;
}

.icon-secondary:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.important-toggle {
    font-size: 20px;
    color: var(--muted);
}

.important-toggle.important {
    color: #d99000;
    background: #fff7df;
    border-color: #f1d28a;
}

.icon-secondary.active {
    background: #e4f3ea;
    border-color: #b8d8c5;
    color: var(--brand-dark);
}

.search {
    display: block;
    padding: 0 12px 10px;
}

.search span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
}

.search input {
    width: 100%;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--line);
    padding: 0 12px;
}

.status-line {
    padding: 0 14px 10px;
}

.sync-diagnostics {
    margin: -4px 8px 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .92);
    overflow: hidden;
    flex: 0 0 auto;
}

.sync-diagnostics-summary {
    width: 100%;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 9px;
    background: var(--panel-soft);
    color: var(--text);
    font-size: 12px;
    font-weight: 800;
    text-align: left;
}

.sync-diagnostics-summary strong {
    color: var(--brand);
    font-size: 11px;
    white-space: nowrap;
}

.sync-diagnostics.slow .sync-diagnostics-summary strong {
    color: #b45309;
}

.sync-diagnostics.error .sync-diagnostics-summary strong {
    color: var(--danger);
}

.sync-diagnostics-details {
    display: grid;
    gap: 6px;
    max-height: min(320px, 34vh);
    overflow: auto;
    padding: 7px;
}

.sync-source {
    display: grid;
    gap: 5px;
    border: 1px solid #d9e7df;
    border-radius: 7px;
    padding: 7px;
    background: #fff;
}

.sync-source.warn {
    border-color: #facc15;
}

.sync-source.error {
    border-color: #fca5a5;
}

.sync-source-head,
.sync-step {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.sync-source-head span,
.sync-step span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sync-source-head {
    font-size: 12px;
    font-weight: 900;
}

.sync-source-head strong,
.sync-step strong {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

.sync-progress {
    position: relative;
    height: 4px;
    border-radius: 999px;
    background: #e5eee9;
    overflow: hidden;
}

.sync-progress i {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    border-radius: inherit;
    background: var(--brand);
    transition: width .22s ease;
}

.sync-source.running .sync-progress i {
    background: var(--brand);
}

.sync-source.warn .sync-progress i {
    background: #d97706;
}

.sync-source.error .sync-progress i {
    background: var(--danger);
}

.sync-steps {
    display: grid;
    gap: 3px;
}

.sync-step {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
}

.sync-step.done span,
.sync-step.done strong {
    color: var(--brand-dark);
}

.sync-step.running span,
.sync-step.running strong {
    color: var(--text);
}

.sync-step.pending {
    opacity: .62;
}

.sync-step.error span,
.sync-step.error strong {
    color: var(--danger);
}

.history-loading-card {
    min-height: 100%;
    display: grid;
    place-items: center;
    padding: 20px;
}

.history-loading-card .sync-source {
    width: min(520px, 100%);
    box-shadow: var(--shadow);
}

.conversation-list {
    overflow: auto;
    padding: 0 8px 12px;
}

.conversation {
    position: relative;
    width: 100%;
    min-height: 74px;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 10px;
    border-radius: 8px;
    background: transparent;
    text-align: left;
    color: var(--text);
    cursor: pointer;
}

.conversation:hover,
.conversation.active {
    background: var(--panel-soft);
}

.conversation.reaction-updated {
    box-shadow: inset 3px 0 0 #ef476f;
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #d6eee0;
    color: var(--brand-dark);
    display: grid;
    place-items: center;
    font-weight: 800;
    overflow: hidden;
    flex: 0 0 auto;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.conv-main {
    min-width: 0;
}

.conv-name,
.conv-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    margin-bottom: 4px;
}

.conv-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-text {
    color: var(--muted);
    font-size: 14px;
    display: -webkit-box;
    max-height: 40px;
    overflow: hidden;
    white-space: normal;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-height: 1.35;
}

.conv-meta-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 5px;
}

.comment-indicator {
    flex: 0 0 auto;
    display: inline-grid;
    place-items: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e4f3ea;
    color: var(--brand-dark);
    font-size: 13px;
    line-height: 1;
    cursor: help;
}

.manager-badge {
    max-width: 100%;
    min-height: 20px;
    display: inline-flex;
    align-items: center;
    border-radius: 10px;
    padding: 0 8px;
    background: color-mix(in srgb, var(--manager-color) 14%, white);
    color: var(--manager-color);
    border: 1px solid color-mix(in srgb, var(--manager-color) 35%, white);
    font-size: 12px;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-badge {
    --source-color: #3f4b5f;
    max-width: 100%;
    min-height: 20px;
    display: inline-flex;
    align-items: center;
    border-radius: 10px;
    padding: 0 8px;
    background: color-mix(in srgb, var(--source-color) 12%, white);
    color: var(--source-color);
    border: 1px solid color-mix(in srgb, var(--source-color) 35%, white);
    font-size: 12px;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conv-time {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

.dialog-important-button {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--line);
    color: var(--muted);
    padding: 0;
    font-size: 15px;
    line-height: 1;
    opacity: 0;
    pointer-events: none;
    transition: opacity .12s ease, background .12s ease, border-color .12s ease, color .12s ease;
}

.dialog-important-button.important {
    opacity: 1;
    pointer-events: auto;
    color: #d99000;
    background: #fff7df;
    border-color: #f1d28a;
}

.dialog-important-button:hover {
    background: #fff3c4;
    color: #a86600;
    border-color: #e4bd58;
}

.conv-read-actions {
    position: absolute;
    top: 9px;
    right: 9px;
    display: inline-flex;
    gap: 4px;
    opacity: 1;
    pointer-events: none;
}

.conversation:hover .conv-read-actions,
.conversation:focus-within .conv-read-actions,
.conversation:focus-visible .conv-read-actions {
    pointer-events: auto;
}

.conversation:hover .conv-read-actions button,
.conversation:focus-within .conv-read-actions button,
.conversation:focus-visible .conv-read-actions button {
    opacity: 1;
    pointer-events: auto;
}

.conv-read-actions button {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--line);
    color: var(--muted);
    padding: 0;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .12s ease, background .12s ease, border-color .12s ease, color .12s ease;
}

.conv-read-actions button:hover {
    background: #e4f3ea;
    color: var(--brand-dark);
    border-color: #b8d8c5;
}

.dialog-state-button {
    position: relative;
    font-weight: 800;
}

.dialog-state-button.unread {
    color: var(--danger);
}

.dialog-state-button.read {
    color: var(--brand);
}

@media (hover: none) {
    .conv-read-actions button {
        opacity: 1;
        pointer-events: auto;
    }
}

.manual-unread-dot {
    width: 24px;
    min-width: 24px;
    padding: 0;
    font-size: 0;
    box-shadow: none;
}

.reaction-dot {
    width: 24px;
    height: 24px;
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    background: #ffe3ec;
    color: #c9184a;
    font-size: 13px;
    animation: reaction-glow 1.2s ease-in-out infinite alternate;
}

.badge {
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    border-radius: 12px;
    background: var(--brand);
    color: #fff;
    display: inline-grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
    flex: 0 0 auto;
}

.badge.manual-unread-dot {
    width: 24px;
    min-width: 24px;
    padding: 0;
    color: transparent;
    font-size: 0;
    box-shadow: none;
}

.chat {
    display: grid;
    grid-template-areas:
        "header"
        "messages"
        "attachments"
        "composer";
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    position: relative;
    height: 100dvh;
    overflow: hidden;
}

.attachments-panel {
    position: absolute;
    inset: 76px 0 0;
    z-index: 20;
    display: none;
    grid-template-rows: auto minmax(0, 1fr) auto;
    background: var(--bg);
    border-left: 1px solid var(--line);
}

.attachments-panel.open {
    display: grid;
}

.activity-panel {
    position: fixed;
    inset: 18px;
    max-width: 1040px;
    width: min(1040px, calc(100vw - 36px));
    max-height: calc(100dvh - 36px);
    margin: auto;
    z-index: 24;
    display: none;
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 18px 60px rgba(31, 41, 55, .22);
    overflow: hidden;
}

.activity-panel.open {
    display: grid;
}

.admin-panel {
    position: fixed;
    inset: 18px;
    max-width: 1080px;
    width: min(1080px, calc(100vw - 36px));
    max-height: calc(100dvh - 36px);
    margin: auto;
    z-index: 25;
    display: none;
    grid-template-rows: auto minmax(0, 1fr);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 18px 60px rgba(31, 41, 55, .22);
    overflow: hidden;
}

.admin-panel.open {
    display: grid;
}

.attachments-panel-head {
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}

.attachments-panel-head h3 {
    margin: 0;
    font-size: 18px;
}

.attachments-panel-head button {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--text);
    font-size: 22px;
}

.activity-panel-head {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}

.activity-panel-head h3 {
    margin: 0;
    font-size: 18px;
}

.activity-panel-head button {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--text);
    font-size: 22px;
}

.attachments-feed {
    min-height: 0;
    overflow: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    align-content: start;
    gap: 12px;
    padding: 14px;
}

.activity-filters {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}

.activity-filters label {
    min-width: 0;
    display: grid;
    gap: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.activity-filters input,
.activity-filters select {
    width: 100%;
    min-height: 34px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel-soft);
    color: var(--text);
    font-size: 13px;
}

.activity-summary {
    display: grid;
    gap: 6px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    background: #f8fbf9;
    color: var(--muted);
    font-size: 13px;
}

.activity-total strong {
    color: var(--text);
}

.activity-summary-line {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.activity-summary-line span {
    padding: 4px 8px;
    border-radius: 8px;
    background: var(--panel);
    border: 1px solid var(--line);
}

.activity-feed {
    min-height: 0;
    overflow: auto;
    display: grid;
    align-content: start;
    gap: 8px;
    padding: 12px 14px;
}

.activity-item {
    display: grid;
    grid-template-columns: minmax(120px, auto) minmax(120px, 1fr) auto;
    gap: 6px 10px;
    align-items: baseline;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    font-size: 13px;
}

.activity-item time {
    color: var(--muted);
    font-size: 12px;
}

.activity-item strong {
    color: var(--text);
}

.activity-item a {
    color: var(--brand-dark);
    font-weight: 700;
    text-decoration: none;
}

.activity-item p {
    grid-column: 1 / -1;
    margin: 0;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.activity-empty {
    padding: 28px 16px;
    color: var(--muted);
    text-align: center;
}

.admin-users {
    min-height: 0;
    overflow: auto;
    display: grid;
    align-content: start;
    gap: 12px;
    padding: 14px;
}

.admin-user-card {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.admin-user-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.admin-role,
.admin-save-state {
    min-height: 18px;
    display: inline-flex;
    align-items: center;
    border-radius: 10px;
    padding: 0 6px;
    font-size: 10px;
    font-weight: 800;
}

.admin-role {
    background: #fff7ed;
    color: #9a3412;
    border: 1px solid #fed7aa;
}

.admin-save-state {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #bbf7d0;
}

.admin-toggle,
.admin-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
}

.admin-toggle input,
.admin-check input {
    width: 16px;
    height: 16px;
}

.admin-section {
    display: grid;
    gap: 8px;
}

.admin-section h4 {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.admin-check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 8px;
}

.admin-check {
    min-height: 34px;
    padding: 7px 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.admin-totp {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.admin-secret {
    max-width: 100%;
    padding: 4px 6px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid var(--line);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 10px;
    overflow-wrap: anywhere;
}

.admin-qr-link {
    color: var(--brand-dark);
    font-size: 11px;
    font-weight: 800;
    text-decoration: none;
}

.admin-page {
    height: auto !important;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    background: var(--bg);
    color: var(--text);
    overscroll-behavior-y: auto;
    -webkit-overflow-scrolling: touch;
}

.admin-layout {
    width: min(1520px, 100%);
    margin: 0 auto;
    padding: 14px;
    display: grid;
    gap: 10px;
}

.admin-page-head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
}

.admin-back {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    border-radius: 8px;
    text-decoration: none;
}

.admin-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.admin-tabs button {
    min-height: 30px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel-soft);
    color: var(--text);
    padding: 0 10px;
    font-weight: 800;
    font-size: 13px;
}

.admin-tabs button.active {
    background: #e4f3ea;
    color: var(--brand-dark);
    border-color: #b8d8c5;
}

.admin-tabs button:disabled {
    opacity: .45;
}

.admin-card {
    min-width: 0;
    display: grid;
    gap: 9px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.admin-card-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.admin-card-head p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.hidden {
    display: none !important;
}

.admin-inline-form {
    display: grid;
    grid-template-columns: 105px 130px 30px max-content;
    align-items: center;
    gap: 6px;
    justify-content: start;
}

.admin-user-form {
    grid-template-columns: 105px 130px 30px max-content;
}

.admin-channel-form {
    grid-template-columns: 110px 82px 130px 112px 78px 30px max-content;
}

.admin-filter-form {
    display: grid;
    grid-template-columns: 132px 132px minmax(150px, 190px) minmax(150px, 190px) auto;
    align-items: center;
    justify-content: start;
    gap: 6px;
}

.admin-inline-form input,
.admin-inline-form select,
.admin-filter-form input,
.admin-filter-form select,
.admin-text-input,
.admin-number-input {
    width: 100%;
    height: 28px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel-soft);
    color: var(--text);
    padding: 0 7px;
    font: inherit;
    font-size: 12px;
}

.admin-inline-form button,
.admin-filter-form button {
    min-height: 28px;
    padding: 0 9px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 800;
}

.admin-table-wrap {
    min-width: 0;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.admin-access-table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12px;
}

.admin-access-table th,
.admin-access-table td {
    min-width: 46px;
    padding: 5px 6px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    text-align: center;
    background: var(--panel);
}

.admin-access-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8fbf9;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
}

.admin-access-table .admin-sticky-col {
    position: sticky;
    left: 0;
    z-index: 3;
    min-width: 166px;
    text-align: left;
    background: var(--panel);
}

.admin-access-table thead .admin-sticky-col {
    z-index: 4;
    background: #f8fbf9;
}

.admin-user-name {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.admin-user-top,
.admin-channel-name {
    min-width: 118px;
}

.admin-user-top {
    vertical-align: top;
}

.admin-user-top .manager-badge,
.admin-channel-name .source-badge {
    margin: 0 auto 4px;
    min-height: 18px;
    padding: 0 6px;
    font-size: 11px;
}

.admin-id {
    display: block;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.2;
    font-weight: 800;
}

.admin-section-row th,
.admin-section-row td {
    background: #f4f8f6;
    color: var(--brand-dark);
    font-weight: 900;
}

.admin-matrix-table td {
    min-width: 124px;
}

.admin-channel-table td {
    min-width: 98px;
}

.admin-channel-table .admin-sticky-col {
    min-width: 172px;
}

.admin-color-input {
    width: 30px;
    height: 24px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: transparent;
}

.admin-totp-cell {
    min-width: 260px;
    text-align: left;
}

.admin-totp-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.admin-mini-button {
    min-height: 24px;
    padding: 0 6px;
    border-radius: 7px;
    font-size: 11px;
    font-weight: 800;
}

.admin-mini-button.danger {
    color: #9f1d1d;
    border-color: #efc4c4;
    background: #fff5f5;
}

.admin-more-button {
    width: fit-content;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 800;
}

.admin-activity-summary {
    display: grid;
    gap: 5px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbf9;
    color: var(--muted);
    font-size: 12px;
}

.admin-activity-feed {
    display: grid;
    gap: 8px;
}

.admin-page .activity-stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.admin-page .activity-server-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.admin-page .activity-server-card,
.admin-page .activity-stat-card,
.admin-page .activity-item {
    padding: 8px;
}

.admin-page .activity-item {
    grid-template-columns: minmax(112px, auto) minmax(120px, 1fr) auto auto;
    font-size: 12px;
}

.admin-page .activity-item em {
    color: var(--muted);
    font-style: normal;
    font-size: 11px;
}

.admin-page .server-metric {
    padding: 7px;
}

.admin-page .server-metric strong {
    font-size: 15px;
}

.admin-page .activity-stat-row {
    min-height: 24px;
    padding: 4px 7px;
    font-size: 12px;
}

@media (max-width: 520px) {
    .admin-layout {
        padding: 8px;
        gap: 8px;
    }

    .admin-page-head {
        grid-template-columns: 1fr auto;
        gap: 8px;
    }

    .admin-page-head h1 {
        grid-column: 1 / -1;
        order: -1;
    }

    .admin-card {
        padding: 8px;
        gap: 8px;
    }

    .admin-tabs {
        gap: 5px;
    }

    .admin-tabs button {
        min-height: 28px;
        padding: 0 8px;
        font-size: 12px;
    }

    .admin-user-form {
        grid-template-columns: minmax(58px, .7fr) minmax(78px, 1fr) 28px 30px;
        gap: 5px;
        width: 100%;
    }

    .admin-channel-form {
        grid-template-columns: minmax(76px, 1fr) 72px minmax(86px, 1fr) 30px;
        gap: 5px;
        width: 100%;
    }

    .admin-channel-form input[name="external_id"],
    .admin-channel-form input[name="local_group_id"] {
        display: none;
    }

    .admin-inline-form input,
    .admin-inline-form select,
    .admin-filter-form input,
    .admin-filter-form select {
        height: 27px;
        padding: 0 5px;
        font-size: 11px;
    }

    .admin-inline-form button {
        width: 30px;
        min-width: 30px;
        padding: 0;
        font-size: 0;
    }

    .admin-inline-form button::before {
        content: "+";
        font-size: 18px;
        line-height: 1;
    }

    .admin-filter-form {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 30px;
        grid-template-areas:
            "from to ."
            "manager action submit";
        gap: 5px;
        width: 100%;
    }

    .admin-filter-form input:nth-of-type(1) {
        grid-area: from;
    }

    .admin-filter-form input:nth-of-type(2) {
        grid-area: to;
    }

    .admin-filter-form select:nth-of-type(1) {
        grid-area: manager;
    }

    .admin-filter-form select:nth-of-type(2) {
        grid-area: action;
    }

    .admin-filter-form button {
        grid-area: submit;
        width: 30px;
        min-width: 30px;
        padding: 0;
        font-size: 0;
    }

    .admin-filter-form button::before {
        content: "↻";
        font-size: 15px;
        line-height: 1;
    }

    .admin-page .activity-stats-grid,
    .admin-page .activity-server-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
    }

    .admin-activity-summary {
        padding: 6px 7px;
        font-size: 11px;
    }

    .activity-summary-line {
        gap: 5px;
    }

    .activity-summary-line span {
        padding: 3px 5px;
    }

    .admin-page .activity-server-card,
    .admin-page .activity-stat-card,
    .admin-page .activity-item {
        padding: 6px;
    }

    .admin-page .server-metric {
        padding: 6px;
        gap: 2px;
    }

    .admin-page .server-metric span,
    .admin-page .server-metric small {
        font-size: 10px;
    }

    .admin-page .server-metric strong {
        font-size: 13px;
    }

    .admin-page .activity-stat-card h4 {
        font-size: 12px;
    }

    .admin-page .activity-stat-row {
        min-height: 22px;
        padding: 3px 5px;
        font-size: 11px;
    }

    .admin-page .activity-item {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 3px 6px;
        font-size: 11px;
    }

    .admin-page .activity-item time,
    .admin-page .activity-item em,
    .admin-page .activity-item p {
        font-size: 10px;
    }

    .admin-page .activity-item p {
        grid-column: 1 / -1;
    }
}

.activity-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.activity-stats-grid.compact {
    margin-top: 12px;
}

.activity-server-card {
    grid-column: 1 / -1;
    display: grid;
    gap: 12px;
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.activity-server-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.activity-server-head h4 {
    margin: 0;
    font-size: 15px;
}

.activity-server-head span {
    color: var(--muted);
    font-size: 12px;
}

.server-alerts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.server-alerts span {
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    background: #eef7f1;
    color: #17643a;
    font-size: 12px;
    font-weight: 700;
}

.server-alerts span.warning {
    background: #fff4d6;
    color: #8a5a00;
}

.server-alerts span.danger {
    background: #ffe0df;
    color: #b42318;
}

.activity-server-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.server-metric {
    min-width: 0;
    display: grid;
    gap: 3px;
    padding: 9px;
    border-radius: 7px;
    background: var(--panel-soft);
}

.server-metric.warning {
    background: #fff8e8;
    box-shadow: inset 3px 0 0 #f2a900;
}

.server-metric.danger {
    background: #fff1f0;
    box-shadow: inset 3px 0 0 #d92d20;
}

.server-metric.ok {
    box-shadow: inset 3px 0 0 #8fc9a8;
}

.server-metric span,
.server-metric small {
    min-width: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.server-metric strong {
    font-size: 17px;
}

.activity-stat-card {
    min-width: 0;
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.activity-stat-card h4 {
    margin: 0;
    font-size: 14px;
}

.activity-stat-card p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.activity-stat-row {
    position: relative;
    min-height: 30px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    padding: 6px 8px;
    overflow: hidden;
    border-radius: 7px;
    background: var(--panel-soft);
}

.activity-stat-row span,
.activity-stat-row strong {
    position: relative;
    z-index: 1;
}

.activity-stat-row.server-row {
    grid-template-columns: minmax(0, 1fr) auto;
}

.activity-stat-row.server-row em {
    position: relative;
    z-index: 1;
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 11px;
    font-style: normal;
}

.activity-stat-row span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.activity-stat-row i {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--bar);
    background: #dcefe5;
}

.activity-more {
    margin: 10px 14px 14px;
}

.attachment-filter {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
}

.attachment-filter span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.attachment-filter.active {
    background: #e4f3ea;
    border-color: #b8d8c5;
    color: var(--brand-dark);
}

.attachments-month {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.attachments-month::before,
.attachments-month::after {
    content: "";
    height: 1px;
    flex: 1;
    background: var(--line);
}

.attachments-month span {
    padding: 5px 10px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .72);
    border: 1px solid var(--line);
}

.attachments-feed-item {
    min-width: 0;
    display: grid;
    grid-template-rows: auto auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    overflow: hidden;
}

.attachments-feed-item.type-photo,
.attachments-feed-item.type-video {
    grid-template-rows: 220px auto;
    min-height: 270px;
}

.attachments-feed-item.type-photo .attachments-feed-media,
.attachments-feed-item.type-video .attachments-feed-media {
    height: 220px;
    overflow: hidden;
}

.attachments-feed-item.type-doc,
.attachments-feed-item.type-audio_message,
.attachments-feed-item.type-link {
    grid-column: span 2;
    grid-template-rows: minmax(78px, auto) auto;
    min-height: 112px;
}

.attachments-feed-item.type-doc .attachments-feed-media,
.attachments-feed-item.type-audio_message .attachments-feed-media,
.attachments-feed-item.type-link .attachments-feed-media {
    min-height: 78px;
    overflow: hidden;
}

.attachments-feed-media {
    min-height: 0;
    display: grid;
    place-items: center;
    padding: 0;
    background: var(--panel-soft);
}

.attachments-feed-media .attachments {
    width: 100%;
    min-height: 0;
    margin: 0;
}

.attachments-feed-media .photo-link {
    height: 220px;
    border-radius: 0;
}

.attachments-feed-media .photo-link,
.attachments-feed-media .gif-attachment {
    width: 100%;
    max-width: 100%;
}

.attachments-feed-media .photo-link img {
    height: 220px;
    min-height: 220px;
    max-height: none;
    border-radius: 0;
}

.attachments-feed-media .photo-link img,
.attachments-feed-media .gif-attachment {
    object-fit: cover;
}

.attachments-feed-media .gif-attachment {
    height: 220px;
    min-height: 220px;
    max-height: none;
    border-radius: 0;
}

.attachments-feed-media .file-link,
.attachment-link-card {
    width: 100%;
    min-height: 78px;
    display: grid;
    align-content: center;
    gap: 8px;
    padding: 14px;
    border-radius: 0;
    background: transparent;
}

.attachments-feed-media .file-link {
    grid-template-columns: 24px minmax(0, 1fr);
    align-items: center;
    color: var(--text);
}

.attachments-feed-media .file-link span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-audio-compact {
    width: 100%;
    min-height: 70px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
}

.attachment-audio-compact audio {
    width: 100%;
    min-width: 0;
    height: 36px;
}

.attachment-audio-compact span {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.video-attachment {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 180px;
    display: grid;
    place-items: center;
    overflow: hidden;
    color: #fff;
    text-decoration: none;
    background: #18231d;
}

.video-attachment img {
    width: 100%;
    height: 100%;
    min-height: 180px;
    object-fit: cover;
    filter: brightness(.76);
}

.video-attachment span,
.attachment-type-icon {
    position: absolute;
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, .5);
    color: #fff;
    font-size: 22px;
}

.attachment-link-card {
    color: var(--text);
    text-decoration: none;
}

.attachment-link-card strong,
.attachment-link-card span,
.attachment-link-card em {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-link-card em {
    color: var(--muted);
    font-size: 12px;
    font-style: normal;
}

.attachments-feed-meta {
    display: grid;
    gap: 3px;
    padding: 9px 10px;
    color: var(--muted);
    font-size: 12px;
}

.attachments-feed-meta span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-weight: 700;
}

.attachments-empty {
    grid-column: 1 / -1;
    align-self: center;
    justify-self: center;
    color: var(--muted);
    padding: 40px 12px;
}

.attachments-more {
    margin: 0 14px 14px;
}

.drop-overlay {
    position: absolute;
    inset: 86px 18px 86px;
    z-index: 10;
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    pointer-events: none;
}

.chat.drag-over .drop-overlay {
    display: grid;
}

.chat.drop-doc-only .drop-overlay {
    grid-template-columns: 1fr;
}

.chat.drop-doc-only .drop-zone-photo {
    display: none;
}

.drop-zone {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 2px dashed #6ab187;
    border-radius: 8px;
    background: rgba(248, 251, 249, .88);
    color: var(--brand-dark);
    text-align: center;
    box-shadow: var(--shadow);
    transition: background .12s ease, border-color .12s ease, transform .12s ease;
}

.drop-zone strong {
    font-size: 22px;
    font-weight: 800;
}

.drop-zone span {
    color: var(--muted);
    font-size: 14px;
}

.chat.drop-as-photo .drop-zone-photo,
.chat.drop-as-doc .drop-zone-doc {
    background: rgba(228, 243, 234, .96);
    border-color: var(--brand);
    transform: scale(1.01);
}

.chat.drop-as-doc .drop-zone-photo,
.chat.drop-as-photo .drop-zone-doc {
    opacity: .68;
}

.chat.drop-doc-only .drop-zone-doc {
    opacity: 1;
}

.back-button {
    grid-area: back;
    display: none;
    font-size: 28px;
}

.chat-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
        "back headline controls"
        "comment comment comment"
        "tags tags tags";
    align-items: start;
    gap: 10px 12px;
}

.chat-headline {
    grid-area: headline;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-identity {
    min-width: 0;
}

.chat-title-row {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
}

.chat-title-row h2 {
    min-width: 0;
}

.chat-title-row h2 a {
    color: inherit;
    text-decoration: none;
}

.chat-title-row h2 a:hover {
    color: var(--brand);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.chat-title-row h2 a.disabled {
    pointer-events: none;
}

.chat-unread-badge {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}

.chat-unread-badge[hidden] {
    display: none !important;
}

.chat-unread-badge.manual {
    width: 13px;
    min-width: 13px;
    height: 13px;
    padding: 0;
}

.chat-identity h2,
.chat-identity p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-controls {
    grid-area: controls;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
}

.dialog-manager-select {
    width: min(172px, 22vw);
    min-width: 132px;
    height: 36px;
}

.dialog-comment-row {
    grid-area: comment;
    min-width: 0;
    width: 100%;
}

.dialog-tags-row {
    grid-area: tags;
    width: 100%;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    padding: 4px 6px;
}

.dialog-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
}

.dialog-tag-chip,
.conv-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 22px;
    border-radius: 11px;
    padding: 0 8px;
    background: #eef7f0;
    color: var(--brand-dark);
    border: 1px solid #cce7d5;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.dialog-tag-chip.crm-tag-chip,
.conv-tag-chip.crm-tag-chip {
    background: #fff7ed;
    color: #9a3412;
    border-color: #fb923c;
    box-shadow: 0 0 0 1px rgba(251, 146, 60, .18);
}

.tag-chip-link,
.conv-tag-chip {
    color: inherit;
    text-decoration: none;
}

.tag-chip-link:hover,
.conv-tag-chip.crm-tag-chip:hover {
    text-decoration: underline;
}

.dialog-tag-chip button {
    width: 16px;
    height: 16px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    font-size: 14px;
    line-height: 1;
}

.dialog-comment-row textarea,
.dialog-manager-select,
#dialogTagInput {
    width: 100%;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--text);
    padding: 7px 10px;
    font-size: 13px;
    transition: border-color .18s ease, box-shadow .18s ease;
}

#dialogTagInput {
    width: auto;
    min-width: 80px;
    flex: 1 1 160px;
    min-height: 24px;
    padding: 0 4px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

#dialogTagInput:focus {
    outline: 0;
}

.chat-controls .dialog-manager-select,
.chat-controls .icon-secondary,
.chat-controls .secondary {
    min-height: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    color: var(--brand-dark);
    font-size: 13px;
}

.chat-controls .icon-secondary,
.chat-controls .secondary {
    width: 36px;
    padding: 0;
}

.chat-controls .secondary {
    overflow: hidden;
    color: var(--brand);
    font-weight: 900;
    position: relative;
}

.chat-controls .secondary[data-action="unread"] {
    color: var(--danger);
}

.chat-controls .secondary:disabled {
    color: var(--muted);
    cursor: default;
}

.dialog-comment-row textarea {
    max-height: 84px;
    resize: none;
    line-height: 1.35;
}

.dialog-comment-row textarea:disabled,
.dialog-manager-select:disabled {
    opacity: .58;
}

.dialog-comment-row .save-ok,
.dialog-manager-select.save-ok {
    border-color: #16a34a;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, .18);
}

.dialog-comment-row .save-error,
.dialog-manager-select.save-error {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(190, 18, 60, .16);
}

.chat-actions {
    display: flex;
    gap: 8px;
}

.messages {
    grid-area: messages;
    min-height: 0;
    overflow: auto;
    overflow-anchor: none;
    padding: 20px;
    background: linear-gradient(#f8fbf9, #eef4f1);
}

.scroll-new-button {
    position: absolute;
    right: 24px;
    bottom: 86px;
    z-index: 18;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 19px;
    background: var(--brand);
    color: #fff;
    box-shadow: var(--shadow);
    font-size: 13px;
    font-weight: 800;
    transition: opacity .16s ease, transform .16s ease;
}

.scroll-new-button.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
}

.scroll-new-button:hover {
    background: var(--brand-dark);
}

.empty-state {
    max-width: 520px;
    margin: 12vh auto 0;
    text-align: center;
    color: var(--muted);
}

.empty-state h3 {
    color: var(--text);
    margin-bottom: 8px;
}

.message {
    max-width: min(680px, 84%);
    margin: 0 0 10px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.date-divider {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 16px 0;
    color: var(--muted);
    font-size: 13px;
}

.date-divider::before,
.date-divider::after {
    content: "";
    height: 1px;
    flex: 1;
    background: var(--line);
}

.date-divider span {
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    border-radius: 14px;
    padding: 0 12px;
    margin: 0 10px;
    background: rgba(255, 255, 255, .74);
    border: 1px solid var(--line);
}

.message.out {
    margin-left: auto;
    align-items: flex-end;
}

.message.unread-message .bubble {
    border-left: 4px solid var(--brand);
    padding-left: 10px;
    box-shadow: 0 1px 2px rgba(19, 35, 27, .08);
}

.bubble-frame {
    position: relative;
    max-width: 100%;
    min-width: 78px;
    width: fit-content;
}

.bubble {
    border-radius: 8px;
    padding: 10px 12px 17px;
    background: var(--panel);
    box-shadow: 0 1px 2px rgba(19, 35, 27, .08);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.bubble .message-link,
.reply-quote .message-link,
.forwarded-message .message-link {
    color: var(--accent);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.bubble code,
.reply-quote code,
.forwarded-message code {
    padding: 1px 4px;
    border-radius: 5px;
    background: rgba(19, 35, 27, .08);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: .92em;
}

.message-pre {
    display: block;
    max-width: 100%;
    margin: 5px 0;
    padding: 8px 10px;
    border-radius: 6px;
    background: rgba(19, 35, 27, .08);
    overflow-x: auto;
    white-space: pre;
}

.message-pre code {
    padding: 0;
    background: transparent;
    white-space: pre;
}

.message-pre-lang {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: .76rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.bubble u,
.reply-quote u,
.forwarded-message u {
    text-underline-offset: 2px;
    text-decoration-thickness: 1.5px;
}

.bubble del,
.reply-quote del,
.forwarded-message del {
    color: var(--muted);
}

.message-spoiler {
    border-radius: 4px;
    background: #dbe4de;
    color: transparent;
    transition: color .12s ease;
}

.message-spoiler:hover {
    color: inherit;
}

.message-quote-line {
    display: block;
    margin: 2px 0;
    padding-left: 8px;
    border-left: 3px solid #b8d8c5;
    color: #415047;
}

.message.out .bubble {
    background: #ffefd7;
}

.message-side-actions {
    position: absolute;
    top: 50%;
    left: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-left: 0;
    padding-left: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .12s ease 1s;
}

.message-side-actions.actions-horizontal {
    width: max-content;
    max-width: none;
    transform: translateY(-50%);
}

.message-side-actions.actions-compact {
    width: 64px;
    transform: translateY(-50%);
}

.message-side-actions.actions-vertical {
    width: 30px;
    transform: translateY(-50%);
}

.message.out .message-side-actions {
    left: auto;
    right: 100%;
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 6px;
}

.bubble-frame:hover .message-side-actions,
.bubble-frame:focus-within .message-side-actions,
.bubble-frame.actions-visible .message-side-actions,
.message-side-actions:hover {
    opacity: 1;
    pointer-events: auto;
    transition-delay: 0s;
}

.message-side-actions button {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .92);
    color: var(--muted);
    border: 1px solid var(--line);
    padding: 0;
    box-shadow: 0 1px 2px rgba(19, 35, 27, .08);
    pointer-events: auto;
}

.bubble-frame:hover .message-side-actions button,
.bubble-frame:focus-within .message-side-actions button,
.bubble-frame.actions-visible .message-side-actions button,
.message-side-actions:hover button {
    pointer-events: auto;
}

.message-side-actions button:hover {
    background: #e4f3ea;
    color: var(--brand-dark);
}

.message-reactions {
    position: absolute;
    left: auto;
    right: -8px;
    bottom: -12px;
    z-index: 2;
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    max-width: calc(100% - 20px);
    justify-content: flex-start;
    margin: 0;
}

.message.out .message-reactions {
    left: -8px;
    right: auto;
    justify-content: flex-end;
}

.bubble-frame:has(.message-reactions) {
    margin-bottom: 10px;
}

.reaction-pill {
    position: relative;
    width: 22px;
    height: 22px;
    min-height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    padding: 0;
    background: rgba(255, 255, 255, .86);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 14px;
    line-height: 1;
    cursor: default;
}

.reaction-pill.own-reaction {
    cursor: pointer;
    box-shadow: 0 0 0 2px rgba(20, 108, 67, .14);
}

.reaction-icon {
    width: 18px;
    height: 18px;
    display: block;
}

.reaction-pop {
    animation: reaction-pop 2s ease-out;
}

.reaction-new {
    border-color: #ef476f;
    color: #c9184a;
    background: #ffe3ec;
    animation: reaction-pop 2s ease-out, reaction-glow 1.2s ease-in-out 4 alternate;
}

.reaction-pop::after,
.reaction-new::after {
    content: "";
    position: fixed;
    left: var(--burst-x, 50vw);
    top: var(--burst-y, 50vh);
    z-index: 3;
    width: 22px;
    height: 22px;
    background-image: var(--reaction-image);
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(10);
    opacity: .5;
    animation: reaction-burst 2s ease-out forwards;
}

.reaction-palette {
    position: fixed;
    z-index: 1000;
    top: 0;
    left: 0;
    width: 240px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-auto-rows: 24px;
    gap: 4px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .98);
    box-shadow: var(--shadow);
}

.message.out .reaction-palette {
    right: auto;
}

.reaction-palette button {
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    padding: 0;
    border-radius: 6px;
    background: transparent;
}

.reaction-palette button:hover {
    background: #e4f3ea;
}

.reaction-palette img {
    width: 20px;
    height: 20px;
}

.reaction-palette .reaction-emoji {
    font-size: 18px;
    line-height: 1;
}

@keyframes reaction-pop {
    0% {
        transform: scale(1.08);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes reaction-burst {
    0% {
        opacity: .5;
        transform: translate(-50%, -50%) scale(10);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes reaction-glow {
    from {
        box-shadow: 0 0 0 rgba(239, 71, 111, 0);
    }
    to {
        box-shadow: 0 0 0 4px rgba(239, 71, 111, .16);
    }
}

.message-meta {
    position: absolute;
    left: 10px;
    bottom: -7px;
    margin: 0;
    padding: 0 6px;
    border-radius: 8px;
    background: var(--panel);
    color: var(--muted);
    font-size: 10px;
    line-height: 14px;
    white-space: nowrap;
}

.message.out .message-meta {
    left: auto;
    right: 10px;
    background: #ffefd7;
}

.message-time[title] {
    cursor: help;
    text-decoration: underline dotted;
    text-underline-offset: 2px;
}

.read-receipt {
    color: var(--brand);
    font-size: 12px;
    font-weight: 900;
}

.receipt-new {
    border-radius: 6px;
    padding: 1px 5px;
    animation: receipt-new 2s ease-out;
}

@keyframes receipt-new {
    0% {
        box-shadow: 0 0 0 0 rgba(20, 108, 67, .58);
        background: #dff3e7;
    }
    55% {
        box-shadow: 0 0 0 5px rgba(20, 108, 67, .18);
        background: #dff3e7;
    }
    100% {
        box-shadow: 0 0 0 0 rgba(20, 108, 67, 0);
        background: transparent;
    }
}

.edit-delay {
    color: var(--muted);
}

.forwarded-block {
    display: grid;
    gap: 5px;
    margin-top: 8px;
    padding: 7px 9px;
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    background: rgba(255, 255, 255, .62);
    color: var(--muted);
    font-size: 13px;
}

.forwarded-message p {
    margin: 2px 0 0;
    color: var(--text);
}

.forwarded-message a {
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
}

.edit-fresh {
    animation: edit-fresh 5s ease-out forwards;
}

@keyframes edit-fresh {
    0%, 45% {
        color: #b42318;
        font-weight: 800;
    }
    100% {
        color: var(--muted);
        font-weight: 400;
    }
}

.reply-quote {
    display: grid;
    gap: 2px;
    margin: 0 0 8px;
    padding: 7px 9px;
    border-left: 3px solid var(--brand);
    border-radius: 6px;
    background: rgba(255, 255, 255, .62);
    color: var(--muted);
    font-size: 13px;
}

.reply-quote strong,
.reply-chip strong {
    color: var(--brand-dark);
    margin-right: 6px;
}

.reply-quote span,
.reply-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachments {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}

.photo-link {
    display: block;
    width: min(280px, 70vw);
    max-width: 100%;
    padding: 0;
    border-radius: 8px;
    background: transparent;
    overflow: hidden;
}

.photo-link img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 280px;
    border-radius: 8px;
    object-fit: cover;
}

.sticker-image {
    display: block;
    width: min(160px, 42vw);
    max-width: 160px;
    max-height: 160px;
    object-fit: contain;
    border-radius: 0;
}

.lottie-sticker {
    position: relative;
    width: min(160px, 42vw);
    height: min(160px, 42vw);
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 13px;
}

.lottie-sticker .sticker-image {
    grid-area: 1 / 1;
}

.lottie-sticker-animation {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
}

.lottie-sticker.animation-ready > .sticker-image {
    opacity: 0;
}

.lottie-sticker svg {
    width: 100%;
    height: 100%;
}

.audio-message {
    display: grid;
    gap: 8px;
    min-width: min(280px, 72vw);
}

.audio-message audio {
    width: 100%;
    max-width: 320px;
}

.audio-transcript {
    display: grid;
    gap: 3px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .62);
    color: var(--muted);
    font-size: 13px;
}

.audio-transcript span {
    color: var(--brand-dark);
    font-weight: 700;
}

.audio-transcript p {
    margin: 0;
    color: var(--text);
    line-height: 1.35;
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(4, 12, 8, .82);
}

.lightbox img {
    max-width: min(1100px, 96vw);
    max-height: 92vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
}

.lightbox-close {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .94);
    color: var(--text);
    font-size: 28px;
    line-height: 1;
}

.image-peek {
    position: fixed;
    z-index: 80;
    border-radius: 8px;
    background-color: #0b1510;
    background-repeat: no-repeat;
    background-size: auto;
    border: 1px solid rgba(255, 255, 255, .22);
    box-shadow: 0 24px 80px rgba(0, 0, 0, .36);
    pointer-events: none;
}

.text-peek {
    position: fixed;
    z-index: 90;
    max-height: min(420px, 70vh);
    overflow: auto;
    border-radius: 8px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, .98);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    color: var(--text);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    pointer-events: none;
}

.toast-stack {
    position: fixed;
    left: 8px;
    bottom: 8px;
    z-index: 120;
    display: grid;
    gap: 8px;
    width: min(360px, calc(100vw - 32px));
    pointer-events: none;
}

.message-toast {
    position: relative;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .98);
    box-shadow: var(--shadow);
    overflow: hidden;
    pointer-events: auto;
    animation: toast-in .18s ease-out;
}

.message-toast.closing {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .18s ease, transform .18s ease;
}

.message-toast-main {
    width: 100%;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 66px;
    padding: 10px 40px 10px 10px;
    background: transparent;
    color: var(--text);
    text-align: left;
}

.message-toast-main:hover {
    background: var(--panel-soft);
}

.message-toast-avatar {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #e7f1ec;
    color: var(--brand-dark);
    font-size: 13px;
    font-weight: 800;
    overflow: hidden;
}

.message-toast-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-toast-content {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.message-toast-content strong,
.message-toast-content span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-toast-content strong {
    font-size: 13px;
    color: var(--brand-dark);
}

.message-toast-content span {
    font-size: 13px;
    color: var(--muted);
}

.message-toast-count {
    min-width: 22px;
    height: 22px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
}

.message-toast-close {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 24px;
    height: 24px;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
}

.message-toast-close:hover {
    background: #f7e6e6;
    color: var(--danger);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 780px) {
    .toast-stack {
        top: max(10px, env(safe-area-inset-top));
        left: 50%;
        right: auto;
        bottom: auto;
        width: min(420px, calc(100vw - 20px));
        transform: translateX(-50%);
        gap: 6px;
        justify-items: stretch;
    }

    .message-toast {
        border-radius: 16px;
        border-color: rgba(255, 255, 255, .58);
        background: rgba(255, 255, 255, .92);
        box-shadow: 0 12px 36px rgba(15, 23, 42, .2);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
        animation: toast-in-mobile .22s cubic-bezier(.2, .8, .2, 1);
    }

    .message-toast.closing {
        transform: translateY(-12px);
    }

    .message-toast-main {
        min-height: 58px;
        grid-template-columns: 38px minmax(0, 1fr) auto;
        gap: 9px;
        padding: 8px 38px 8px 9px;
    }

    .message-toast-avatar {
        width: 38px;
        height: 38px;
    }

    .message-toast-content strong,
    .message-toast-content span {
        font-size: 12.5px;
    }

    .message-toast-close {
        top: 50%;
        right: 8px;
        transform: translateY(-50%);
        background: rgba(15, 23, 42, .06);
    }
}

@keyframes toast-in-mobile {
    from {
        opacity: 0;
        transform: translateY(-14px) scale(.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.file-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #edf4ff;
    color: #174ea6;
    text-decoration: none;
}

.download-icon {
    width: 22px;
    height: 22px;
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    background: #d8e8ff;
    font-weight: 800;
}

.gif-attachment {
    display: block;
    width: min(280px, 70vw);
    max-height: 280px;
    border-radius: 8px;
    object-fit: contain;
    background: #000;
}

.composer {
    grid-area: composer;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 12px;
    border-top: 1px solid var(--line);
    background: var(--panel);
}

.attach-button input {
    display: none;
}

.composer textarea {
    min-height: 42px;
    max-height: 140px;
    resize: none;
    border-radius: 8px;
    border: 1px solid var(--line);
    padding: 10px 12px;
}

.composer button[type="submit"] {
    min-width: 112px;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    padding: 0 18px;
}

.composer button:disabled,
.secondary:disabled,
textarea:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.attachment-strip {
    grid-area: attachments;
    display: none;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    padding: 0 12px 12px 64px;
    background: var(--panel);
}

.chat-header {
    grid-area: header;
}

.attachment-strip:not(:empty) {
    display: flex;
}

.reply-chip {
    max-width: min(620px, 100%);
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #b9e3c7;
    border-radius: 8px;
    padding: 7px 8px 7px 10px;
    background: #e7f8ee;
    color: var(--muted);
}

.edit-chip {
    border-color: #bfd4ff;
    background: #edf4ff;
}

.reply-chip > span {
    white-space: nowrap;
}

.clear-reply {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .72);
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
}

.attachment-chip {
    max-width: min(520px, 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px;
    background: var(--panel-soft);
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
}

.attachment-name {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-left: 4px;
}

.attachment-mode {
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    border-radius: 8px;
    padding: 0 8px;
    background: #edf4ff;
    color: #174ea6;
    font-size: 13px;
}

.mode-toggle {
    display: inline-grid;
    grid-template-columns: repeat(2, minmax(54px, 1fr));
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.mode-toggle button {
    min-height: 28px;
    padding: 0 8px;
    background: #fff;
    color: var(--muted);
    font-size: 13px;
}

.mode-toggle button + button {
    border-left: 1px solid var(--line);
}

.mode-toggle button.active {
    background: var(--brand);
    color: #fff;
}

.remove-attachment {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: #f1f4f2;
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
}

.remove-attachment:hover {
    background: #fee4e2;
    color: var(--danger);
}

@media (max-width: 1180px) {
    .app-shell {
        display: block;
        height: 100dvh;
        min-height: 0;
        overflow: hidden;
    }

    .layout-resizer {
        display: none;
    }

    .sidebar,
    .chat {
        height: 100dvh;
        min-height: 0;
    }

    .chat {
        display: none;
    }

    .app-shell.chat-open .sidebar {
        display: none;
    }

    .app-shell.chat-open .chat {
        display: grid;
    }

    .back-button {
        display: grid;
    }
}

@media (max-width: 780px) {
    .activity-panel {
        inset: 0;
    }

    .activity-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .activity-item {
        grid-template-columns: minmax(0, 1fr);
    }

    .activity-stats-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .activity-server-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .chat-header {
        grid-template-columns: auto minmax(0, 1fr) minmax(156px, 54%);
        grid-template-areas:
            "back headline controls"
            "comment comment comment"
            "tags tags tags";
        align-items: center;
        gap: 8px;
        padding: 10px;
        min-height: 68px;
    }

    .chat-headline {
        display: flex;
        gap: 8px;
        min-width: 0;
    }

    .chat-headline .avatar {
        width: 40px;
        height: 40px;
        align-self: center;
    }

    .chat-identity {
        min-width: 0;
    }

    .chat-controls {
        grid-area: controls;
        width: 100%;
        justify-self: stretch;
        align-self: center;
        display: grid;
        grid-template-columns: minmax(0, 1fr) repeat(3, 36px);
        gap: 6px;
    }

    .dialog-comment-row {
        grid-area: comment;
    }

    .dialog-manager-select {
        min-width: 0;
        width: 100%;
        height: 36px;
    }

    .dialog-comment-row textarea {
        min-height: 38px;
    }

    .chat-actions .secondary {
        width: 36px;
        padding: 0;
        overflow: hidden;
        color: var(--brand);
        font-weight: 900;
        position: relative;
    }

    .chat-actions .secondary[data-action="unread"] {
        color: var(--danger);
    }

    .chat-controls .icon-secondary,
    .chat-controls .secondary {
        width: 36px;
        height: 36px;
        min-height: 36px;
    }

    .chat-actions #notifyBtn::after {
        content: "!";
        color: var(--text);
        position: absolute;
        inset: 0;
        display: grid;
        place-items: center;
        font-weight: 800;
    }

    .chat-actions #testNotifyBtn::after {
        content: "T";
        color: var(--text);
        position: absolute;
        inset: 0;
        display: grid;
        place-items: center;
        font-weight: 800;
    }

    .messages {
        padding: 12px;
    }

    .scroll-new-button {
        right: 14px;
        bottom: 74px;
        min-height: 34px;
        padding: 0 12px;
        font-size: 12px;
    }

    .attachments-panel {
        inset: 68px 0 0;
    }

    .attachments-feed {
        grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
        gap: 8px;
        padding: 10px;
    }

    .attachments-feed-item.type-doc,
    .attachments-feed-item.type-audio_message,
    .attachments-feed-item.type-link {
        grid-column: 1 / -1;
    }

    .attachments-feed-media .photo-link,
    .attachments-feed-media .photo-link img,
    .attachments-feed-media .gif-attachment,
    .video-attachment,
    .video-attachment img {
        height: 168px;
        min-height: 168px;
    }

    .attachment-audio-compact {
        align-items: stretch;
        flex-direction: column;
        gap: 4px;
    }

    .message {
        max-width: calc(100% - 46px);
    }

    .message-side-actions {
        position: absolute;
        top: 50%;
        left: 100%;
        width: auto;
        max-width: none;
        margin: 0;
        padding-left: 4px;
        padding-right: 0;
        opacity: 1;
        pointer-events: auto;
        display: grid;
        grid-template-columns: repeat(2, 24px);
        gap: 4px;
        transform: translateY(-50%);
    }

    .message-side-actions.actions-horizontal {
        grid-template-columns: repeat(4, 24px);
        width: max-content;
        transform: translateY(-50%);
    }

    .message-side-actions.actions-compact {
        grid-template-columns: repeat(2, 24px);
        width: 52px;
        transform: translateY(-50%);
    }

    .message-side-actions.actions-vertical {
        grid-template-columns: 24px;
        width: 24px;
        transform: translateY(-50%);
    }

    .message.out .message-side-actions {
        left: auto;
        right: 100%;
        margin: 0;
        padding-left: 0;
        padding-right: 4px;
    }

    .bubble-frame:hover .message-side-actions,
    .bubble-frame:focus-within .message-side-actions,
    .bubble-frame.actions-visible .message-side-actions {
        opacity: 1;
        pointer-events: auto;
    }

    .message-side-actions button {
        pointer-events: auto;
    }

    .composer {
        grid-template-columns: 42px minmax(0, 1fr) 48px;
        gap: 8px;
        padding: 10px;
    }

    .composer button[type="submit"] {
        min-width: 48px;
        padding: 0;
        font-size: 0;
    }

    .composer button[type="submit"]::after {
        content: "→";
        font-size: 22px;
    }

    .attachment-strip {
        padding-left: 10px;
    }

    .attachment-chip {
        width: 100%;
        justify-content: space-between;
    }

    .reply-chip {
        width: 100%;
        justify-content: space-between;
    }

    .attachment-name {
        max-width: min(42vw, 220px);
    }

    .drop-overlay {
        inset: 78px 10px 86px;
        grid-template-columns: 1fr;
        grid-template-rows: repeat(2, minmax(0, 1fr));
    }

    .drop-zone strong {
        font-size: 18px;
    }
}
    transform: translateY(-50%);
