:root {
    --bg: #ecf1f7;
    --surface: #ffffff;
    --surface-alt: #d8e4ef;
    --border: #b2c9df;
    --text: #1f2e3b;
    --muted: #5b87ab;
    --accent: #DBA507;
    --accent-strong: #b58b06;
    --user-bubble: #d8e4ef;
    --vet-bubble: #c5d6e7;
    --system-bubble: #ecf1f7;
    --accent-rgb: 219, 165, 7;
    --text-rgb: 31, 46, 59;
    --shadow: 0 20px 50px rgba(31, 46, 59, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    font-family: "Segoe UI", sans-serif;
    color: var(--text);
    background: #ffffff;
    overflow: hidden;
}

body.gallery-open {
    overflow: hidden;
}

.app-shell {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 20px 40px;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.app-header {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.app-header-main {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.app-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.app-header h1 {
    margin: 0;
    font-size: 1.7rem;
    line-height: 1;
    white-space: nowrap;
    color: var(--text);
}

.app-header-logo {
    width: auto;
    height: 1.7rem;
    flex: 0 0 auto;
}

.header-staff-label,
.header-link-button {
    display: inline-flex;
    align-items: center;
    font-family: "Segoe UI", sans-serif;
    font-size: 0.85rem;
    font-weight: 400;
    line-height: 1;
    white-space: nowrap;
    color: var(--text);
}

.eyebrow {
    margin: 0;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.8rem;
}

.chat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.login-panel {
    max-width: 360px;
    margin: 0 auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--muted);
    font-size: 0.92rem;
}

.login-form input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

.workspace-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 20px;
    min-height: 0;
    flex: 1 1 auto;
    align-items: stretch;
}

.chat-sidebar {
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    min-height: 0;
    overflow: hidden;
}

.chat-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    overflow-x: auto;
    overflow-y: auto;
}

.search-box {
    display: flex;
    flex-direction: column;
    margin: 0 0 14px;
}

.search-input-wrap {
    position: relative;
    display: block;
}

.search-input-icon {
    position: absolute;
    top: 50%;
    left: 12px;
    width: 18px;
    height: 18px;
    color: var(--muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 10px 12px 10px 40px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}

.search-result {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(var(--accent-rgb), 0.28);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.78);
    color: var(--text);
    text-align: left;
}

.search-result:hover {
    background: #fff;
}

.search-result[data-can-open="false"] {
    cursor: default;
}

.search-result-title,
.search-result-meta,
.search-result-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-result-title {
    font-weight: 700;
}

.channel-title {
    display: inline-flex;
    align-items: center;
    gap: 0.45em;
    min-width: 0;
}

.channel-title-logo {
    width: auto;
    height: 1em;
    border-radius: 0.22em;
    flex: 0 0 auto;
}

.channel-title-lock {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    height: 1em;
    color: var(--muted);
    flex: 0 0 auto;
}

.channel-title-lock svg {
    width: 100%;
    height: 100%;
}

.search-result-meta,
.search-result-text,
.search-empty {
    color: var(--muted);
    font-size: 0.86rem;
}

.search-empty {
    padding: 10px 12px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.5);
}

.chat-list-item {
    width: 100%;
    text-align: left;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    padding: 12px 14px;
}

.chat-list-item.active {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.chat-list-item.active .chat-list-meta-line,
.chat-list-item.active .chat-list-preview,
.chat-list-item.active .chat-list-phone-line,
.chat-list-item.active .chat-list-chip-row,
.chat-list-item.active .chat-list-intake-line,
.chat-list-item.active .chat-list-intake-label,
.chat-list-item.active .chat-list-intake-separator,
.chat-list-item.active .chat-list-meta-time,
.chat-list-item.active .chat-list-meta-primary,
.chat-list-item.active .chat-list-meta-source,
.chat-list-item.active .chat-list-client-title,
.chat-list-item.active .chat-list-title {
    color: #fff;
}

.chat-list-item.active .chat-list-chip {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.45);
    color: #fff;
}

.chat-list-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.chat-list-title {
    display: block;
    font-weight: 700;
    margin-bottom: 4px;
}

.chat-list-phone-line {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.2;
}

.chat-list-phone-icon {
    width: 1em;
    height: 1em;
    flex: 0 0 auto;
    background: currentColor;
    mask: url("/web-ui/mobile-phone-outline.svg") center / contain no-repeat;
    -webkit-mask: url("/web-ui/mobile-phone-outline.svg") center / contain no-repeat;
}

.chat-list-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 2px 0 5px;
}

.chat-list-chip {
    padding: 3px 7px;
    font-size: 0.72rem;
    line-height: 1.2;
    white-space: normal;
}

.chat-list-intake-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.25;
}

.chat-list-intake-label {
    color: var(--text);
    font-weight: 600;
}

.chat-list-intake-separator {
    color: var(--muted);
}

.chat-list-meta-line,
.chat-list-preview {
    display: block;
    color: var(--muted);
    font-size: 0.9rem;
}

.chat-list-meta-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
}

.chat-list-meta-primary,
.chat-list-meta-source,
.chat-list-meta-time {
    display: inline-flex;
    align-items: center;
    gap: 0.45em;
    font-weight: 400;
}

.chat-list-meta-time {
    flex: 0 0 auto;
    text-align: right;
}

.chat-list-client-title {
    display: inline-flex;
    align-items: center;
    gap: 0.45em;
    min-width: 0;
}

.chat-preview-attachment {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
}

.chat-preview-attachment img {
    width: 1em;
    height: 1em;
    flex: 0 0 auto;
}

.chat-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
}

.chat-meta-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-meta-header-top {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.chat-meta-title {
    margin: 0;
    font-size: 1.35rem;
    flex: 1 1 auto;
    min-width: 0;
}

.active-chat-title-row {
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    gap: 16px;
}

.active-chat-title-main {
    display: inline-flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.active-chat-number-inline {
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 400;
    white-space: nowrap;
}

.active-chat-header-right {
    display: inline-flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 14px;
    flex: 0 0 auto;
    flex-wrap: wrap;
}

.active-chat-id {
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.2;
    white-space: nowrap;
}

.chat-meta-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.meta-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.75);
    color: var(--text);
    font-size: 0.85rem;
    white-space: nowrap;
}

.meta-chip.number {
    background: rgba(121, 104, 87, 0.1);
    color: var(--muted);
}

.meta-chip.status-created,
.meta-chip.lock-free {
    background: rgba(var(--accent-rgb), 0.08);
    color: var(--accent-strong);
}

.meta-chip.unread-count {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 700;
    min-width: 28px;
    justify-content: center;
}

.meta-chip.status-in-progress,
.meta-chip.lock-mine {
    background: var(--accent);
    border-color: var(--accent-strong);
    color: #fff;
}

.meta-chip.mode-parallel,
.meta-chip.mode-round-robin {
    background: rgba(121, 104, 87, 0.1);
    color: var(--muted);
}

.meta-chip.status-sent {
    background: rgba(33, 120, 160, 0.12);
    color: #205f7d;
}

.meta-chip.status-closed,
.meta-chip.status-cancelled,
.meta-chip.lock-busy {
    background: rgba(121, 104, 87, 0.12);
    color: var(--muted);
}

.chat-description {
    margin: 0;
    max-width: 420px;
    color: var(--muted);
}

.admin-chat-header-actions {
    display: inline-flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
    font-size: 0.92rem;
    line-height: 1.2;
    white-space: nowrap;
    flex: 0 0 auto;
}

.admin-chat-header-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    text-decoration: none;
    cursor: pointer;
}

.admin-chat-header-action-icon {
    display: inline-flex;
    width: 1.05rem;
    height: 1.05rem;
    flex: 0 0 auto;
}

.admin-chat-header-action-icon svg {
    width: 100%;
    height: 100%;
}

.admin-chat-header-action:hover {
    color: var(--text);
}

.admin-chat-header-action.is-disabled {
    opacity: 0.5;
    cursor: default;
    pointer-events: none;
}

.admin-chat-header-action-separator {
    color: var(--muted);
}

.admin-chat-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 14px;
}

.admin-chat-actions .secondary-button {
    cursor: pointer;
}

.admin-chat-actions .secondary-button:disabled {
    cursor: default;
    opacity: 0.6;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    font-family: "Segoe UI", sans-serif;
    font-size: 0.85rem;
    font-weight: 400;
    line-height: 1;
    white-space: nowrap;
    color: var(--text);
    cursor: pointer;
}

.header-link-button,
.logout-button {
    border: 0;
    background: transparent;
    padding: 0;
    cursor: pointer;
    text-decoration: none;
}

.notification-control.is-enabled {
    color: var(--accent-strong);
}

.notification-control.is-blocked {
    color: var(--muted);
}

.status-badge img {
    width: 1rem;
    height: 1rem;
    flex: 0 0 auto;
}

.status-badge-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.8rem;
    min-height: 1.2rem;
    padding: 0.05rem 0.35rem;
    border-radius: 999px;
}

.status-badge.is-online {
    color: var(--text);
}

.status-badge.is-online .status-badge-toggle {
    background: var(--accent);
    border: 1px solid var(--accent-strong);
}

.status-badge.is-offline {
    color: var(--text);
    opacity: 1;
}

.status-badge.is-offline .status-badge-toggle {
    background: rgba(31, 46, 59, 0.08);
    border: 1px solid rgba(31, 46, 59, 0.2);
}

.header-action-separator {
    color: var(--text);
    font-size: 0.85rem;
    line-height: 1;
}

.message-history {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    flex: 1 1 auto;
    max-height: none;
    overflow-y: auto;
    overflow-x: auto;
    padding: 8px 4px 12px;
}

.message-date-separator {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: 0.78rem;
    justify-content: center;
    margin: 4px 0;
}

.message-date-separator::before,
.message-date-separator::after {
    content: "";
    height: 1px;
    flex: 1 1 auto;
    background: var(--border);
}

.message-date-separator span {
    flex: 0 0 auto;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
}

.jump-to-latest {
    position: absolute;
    right: 16px;
    bottom: 16px;
    min-height: 34px;
    padding: 7px 12px;
    border-radius: 999px;
    box-shadow: 0 10px 24px rgba(34, 28, 23, 0.16);
    z-index: 2;
}

.message {
    max-width: 80%;
    border-radius: 18px;
    padding: 12px 14px;
    border: 1px solid var(--border);
}

.message.user {
    align-self: flex-start;
    background: #fff;
}

.message.vet {
    align-self: flex-end;
    background: #fff;
}

.message.system {
    align-self: center;
    max-width: min(92%, 620px);
    background: transparent;
    border: 0;
    padding: 0 2px;
}

.message-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.85rem;
}

.message-text {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.5;
}

.message-link-preview {
    display: grid;
    gap: 4px;
    margin-top: 10px;
    padding: 12px 14px;
    border: 1px solid rgba(var(--accent-rgb), 0.18);
    border-left: 4px solid var(--accent);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.72);
    color: inherit;
    text-decoration: none;
}

.message-link-preview:hover {
    border-color: rgba(var(--accent-rgb), 0.38);
    background: rgba(255, 255, 255, 0.9);
}

.message-link-preview-title,
.message-link-preview-url {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-link-preview-title {
    color: var(--text);
    font-weight: 700;
}

.message-link-preview-url {
    color: var(--muted);
    font-size: 0.86rem;
}

.message.system .message-meta {
    justify-content: flex-start;
    gap: 6px;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 0.78rem;
}

.message.system .message-meta strong {
    font-weight: 400;
}

.message.system .message-text {
    color: #808080;
    font-size: 0.8rem;
    line-height: 1.35;
}

.message-attachments,
.attachment-list {
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.attachment-list li {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--accent-strong);
    text-decoration: none;
    font-size: 0.92rem;
}

.message-attachment-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid rgba(var(--accent-rgb), 0.16);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.68);
}

.message-attachment-card.is-image {
    padding: 0;
    overflow: hidden;
}

.message-attachment-card.is-video {
    padding: 12px;
}

.message-attachment-card.is-deleted {
    opacity: 0.8;
}

.message-attachment-body {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
}

.message-attachment-icon,
.attachment-card-icon {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: rgba(var(--accent-rgb), 0.08);
    color: var(--accent-strong);
}

.message-attachment-icon svg,
.attachment-card-icon svg {
    width: 22px;
    height: 22px;
}

.attachment-icon-label {
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.message-attachment-meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-attachment-meta strong,
.message-attachment-meta span,
.message-image-caption {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-attachment-meta span,
.message-image-caption {
    color: var(--muted);
    font-size: 0.88rem;
}

.message-attachment-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(var(--accent-rgb), 0.24);
    background: rgba(var(--accent-rgb), 0.06);
    color: var(--accent-strong);
    text-decoration: none;
    white-space: nowrap;
}

.message-attachment-link:hover {
    background: rgba(var(--accent-rgb), 0.12);
}

.message-image-button {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    padding: 0;
    background: transparent;
    color: inherit;
    border: 0;
    border-radius: 0;
    overflow: hidden;
    cursor: zoom-in;
}

.message-image-button.is-load-error {
    cursor: pointer;
}

.message-video-button {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    padding: 0;
    background: transparent;
    color: inherit;
    border: 0;
    border-radius: 0;
    overflow: hidden;
    cursor: pointer;
}

.message-video-poster {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    background:
        linear-gradient(135deg, rgba(var(--accent-rgb), 0.18), rgba(var(--text-rgb), 0.18)),
        radial-gradient(circle at top, rgba(255, 255, 255, 0.18), transparent 48%);
}

.message-video-play {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--accent-strong);
    font-size: 1.8rem;
    box-shadow: 0 18px 42px rgba(44, 36, 28, 0.18);
}

.message-image-frame {
    position: relative;
    display: block;
    width: 100%;
    min-height: 156px;
    background: rgba(44, 36, 28, 0.08);
}

.message-image-preview {
    display: block;
    width: 100%;
    min-height: 156px;
    max-height: 280px;
    object-fit: cover;
}

.message-image-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px;
    color: var(--muted);
    text-align: center;
    background: rgba(255, 255, 255, 0.78);
}

.message-image-fallback small {
    color: var(--accent-strong);
    font-size: 0.82rem;
}

.message-image-caption {
    padding: 10px 12px 12px;
    text-align: left;
}

.message-attachment-player,
.message-attachment-audio {
    width: 100%;
}

.message-attachment-audio {
    min-width: 0;
}

.attachment-list li.attachment-card {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(215, 199, 176, 0.8);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.75);
}

.attachment-card-preview {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface-alt);
    border: 1px solid rgba(215, 199, 176, 0.9);
}

.attachment-card-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attachment-card-icon {
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.attachment-card-meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.attachment-card-meta strong,
.attachment-card-meta span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-card-meta span {
    color: var(--muted);
}

.attachment-remove-button {
    border: 1px solid rgba(var(--accent-rgb), 0.3);
    background: rgba(var(--accent-rgb), 0.06);
    color: var(--accent-strong);
    border-radius: 999px;
    padding: 8px 12px;
    font: inherit;
    cursor: pointer;
}

.attachment-remove-button:hover {
    background: rgba(var(--accent-rgb), 0.12);
}

.composer-dropzone {
    position: relative;
}

.attachment-picker {
    position: relative;
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid rgba(var(--accent-rgb), 0.22);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.95);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.attachment-picker input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
}

.attachment-picker:hover {
    border-color: rgba(var(--accent-rgb), 0.45);
    background: rgba(var(--accent-rgb), 0.08);
    box-shadow: 0 6px 18px rgba(var(--accent-rgb), 0.12);
}

.attachment-picker-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    color: var(--accent-strong);
    flex: 0 0 auto;
}

.attachment-picker-icon img {
    width: 20px;
    height: 20px;
}

.empty-state {
    padding: 48px 12px;
    text-align: center;
    color: var(--muted);
    border: 1px dashed var(--border);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.5);
}

.composer {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
    padding: 14px;
    border: 1px solid rgba(215, 199, 176, 0.7);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.45);
}

.composer.composer-collapsed {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
}

.composer.composer-collapsed .composer-footer {
    display: contents;
}

.composer.composer-collapsed .composer-assist {
    grid-column: 1;
    align-self: center;
}

.composer.composer-collapsed .composer-actions {
    grid-column: 2;
    justify-content: flex-end;
}

.composer-label {
    display: none;
}

.composer-footer {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.composer-assist {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1 1 auto;
}

.composer-state,
.composer-hint {
    margin: 0;
    color: #808080;
    font-size: 0.8rem;
    line-height: 1.35;
}

.composer-hint {
    white-space: pre-wrap;
}

.toast-container {
    position: fixed;
    right: 24px;
    bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(360px, calc(100vw - 32px));
    z-index: 30;
    pointer-events: none;
}

.toast {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: start;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 14px 32px rgba(34, 28, 23, 0.18);
    overflow: hidden;
    pointer-events: auto;
}

.toast-warning {
    border-left-color: #b56b28;
}

.toast-content,
.toast-dismiss {
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.toast-content {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    padding: 12px 4px 12px 12px;
    text-align: left;
}

.toast-title {
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.25;
}

.toast-body {
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.toast-dismiss {
    min-width: 32px;
    min-height: 32px;
    margin: 5px 5px 0 0;
    border-radius: 50%;
    color: var(--muted);
    font-size: 0.9rem;
}

.toast-dismiss:hover,
.toast-content:hover {
    background: rgba(var(--accent-rgb), 0.08);
}

textarea {
    width: 100%;
    resize: vertical;
    min-height: 110px;
    padding: 14px 58px 14px 14px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: #fff;
    font: inherit;
    color: inherit;
}

.attachment-drop-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px dashed rgba(var(--accent-rgb), 0.55);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
    text-align: center;
    pointer-events: none;
}

.attachment-drop-overlay-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: rgba(var(--accent-rgb), 0.1);
}

.attachment-drop-overlay-icon img {
    width: 24px;
    height: 24px;
}

.composer-dropzone.is-dragover textarea {
    border-color: rgba(var(--accent-rgb), 0.5);
    background: rgba(var(--accent-rgb), 0.04);
}

.composer-locked textarea {
    background: #eef4f9;
    color: var(--muted);
}

.composer-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex: 0 0 auto;
}

button,
.secondary-link {
    appearance: none;
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

button {
    background: var(--accent);
    color: #fff;
}

button:hover {
    background: var(--accent-strong);
}

.secondary-button,
.secondary-link {
    background: var(--surface-alt);
    color: var(--text);
    border: 1px solid var(--border);
    cursor: pointer;
}

.logout-button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text);
    font-size: 0.85rem;
    cursor: pointer;
}

.logout-button img {
    width: auto;
    height: 0.95em;
    flex: 0 0 auto;
}

.logout-button:hover,
.status-badge:hover {
    background: transparent;
    color: var(--text);
}

.status-badge.is-online:hover {
    background: transparent;
}

.compact-button {
    padding: 8px 14px;
    font-size: 0.9rem;
}

.modal-dialog {
    width: min(920px, calc(100vw - 24px));
    padding: 0;
    border: 0;
    border-radius: 28px;
    background: transparent;
    box-shadow: none;
}

.modal-dialog::backdrop {
    background: rgba(33, 26, 20, 0.5);
    backdrop-filter: blur(6px);
}

.modal-shell {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 28px;
    box-shadow: var(--shadow);
}

.modal-wide-shell {
    width: min(920px, calc(100vw - 24px));
}

.modal-compact-shell {
    width: min(420px, calc(100vw - 24px));
}

.modal-header {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    justify-content: space-between;
}

.modal-header h2 {
    margin: 4px 0 0;
    font-size: 1.35rem;
}

.modal-note {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.modal-shell label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--muted);
    font-size: 0.92rem;
}

.modal-shell input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

.modal-checkbox {
    flex-direction: row !important;
    align-items: center;
    gap: 10px !important;
}

.modal-checkbox input {
    width: auto;
    margin: 0;
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.modal-actions-end {
    justify-content: flex-end;
}

.operators-table-wrap {
    overflow-x: auto;
    border: 1px solid rgba(215, 199, 176, 0.8);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.6);
}

.operators-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

.operators-table th,
.operators-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid rgba(215, 199, 176, 0.7);
    vertical-align: middle;
}

.operators-table th {
    color: var(--muted);
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.operators-table tbody tr:last-child td {
    border-bottom: 0;
}

.operators-empty-cell {
    text-align: center !important;
    color: var(--muted);
}

.operators-actions-column {
    width: 180px;
}

.operators-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.operators-row-actions .secondary-button,
.operators-row-actions .danger-button {
    cursor: pointer;
}

.settings-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px;
    border: 1px solid rgba(215, 199, 176, 0.85);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.58);
}

.settings-tab {
    flex: 1 1 150px;
    padding: 10px 14px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.settings-tab:hover,
.settings-tab:focus-visible {
    border-color: rgba(215, 199, 176, 0.9);
    background: rgba(255, 255, 255, 0.68);
    color: var(--text);
}

.settings-tab.is-active {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.settings-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.settings-panel[hidden] {
    display: none;
}

.admin-settings-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px 20px;
    border: 1px solid rgba(215, 199, 176, 0.8);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.68);
}

.admin-settings-token-row {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.admin-settings-token-value {
    color: var(--text);
    font-family: Consolas, "Courier New", monospace;
    word-break: break-all;
}

.admin-settings-token-field {
    margin: 0;
}

.admin-settings-actions {
    margin-top: 0;
}

.admin-settings-section-head h3 {
    margin: 0;
    font-size: 1rem;
}

.admin-settings-section-head p {
    margin: 4px 0 0;
    color: var(--muted);
    line-height: 1.45;
}

.admin-revision-form {
    display: grid;
    grid-template-columns: minmax(140px, 0.75fr) minmax(180px, 1fr) auto;
    gap: 10px;
    align-items: end;
}

.admin-revision-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-revision-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid rgba(215, 199, 176, 0.75);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.72);
}

.admin-revision-item strong {
    display: block;
}

.admin-revision-item span {
    color: var(--muted);
    font-size: 0.86rem;
}

.operators-state-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 68px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(121, 104, 87, 0.12);
    color: var(--muted);
    font-size: 0.84rem;
}

.operators-state-pill.is-on {
    background: rgba(39, 117, 76, 0.12);
    color: #1f6b45;
}

.danger-button {
    background: rgba(164, 25, 25, 0.12);
    color: #8e2d2d;
    border: 1px solid rgba(164, 25, 25, 0.18);
}

.danger-button:hover {
    background: rgba(164, 25, 25, 0.18);
}

.attachment-gallery {
    position: fixed;
    inset: 0;
    z-index: 1000;
}

.attachment-gallery-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 14, 10, 0.82);
    backdrop-filter: blur(6px);
}

.attachment-gallery-dialog {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    width: min(1120px, calc(100vw - 32px));
    height: min(88vh, 920px);
    margin: 4vh auto;
    padding: 24px;
}

.attachment-gallery-figure {
    margin: 0;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    justify-content: center;
}

.attachment-gallery-image {
    display: block;
    max-width: 100%;
    max-height: calc(88vh - 96px);
    border-radius: 22px;
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.34);
    background: rgba(255, 255, 255, 0.08);
}

.attachment-gallery-video {
    display: block;
    width: min(100%, 960px);
    max-height: calc(88vh - 96px);
    border-radius: 22px;
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.34);
    background: rgba(0, 0, 0, 0.45);
}

.attachment-gallery-caption {
    color: #f7f1e8;
    text-align: center;
    max-width: min(760px, 100%);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-gallery-nav,
.attachment-gallery-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    backdrop-filter: blur(8px);
}

.attachment-gallery-nav {
    width: 56px;
    height: 56px;
    padding: 0;
    font-size: 2rem;
}

.attachment-gallery-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 1.8rem;
}

.attachment-gallery-nav:hover,
.attachment-gallery-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

@media (min-width: 1200px) {
    .app-shell {
        max-width: 1320px;
        padding-right: 24px;
        padding-left: 24px;
    }

    .workspace-layout {
        grid-template-columns: minmax(300px, 340px) minmax(0, 1fr);
        gap: 24px;
    }
}

@media (max-width: 720px) {
    .workspace-layout {
        grid-template-columns: 1fr;
    }

    .app-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .app-header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .chat-description {
        max-width: none;
        text-align: left;
    }

    .chat-meta-header-top {
        flex-direction: column;
        align-items: flex-start;
    }

    .active-chat-header-right {
        justify-content: flex-start;
    }

    .active-chat-title-main {
        gap: 10px;
    }

    .admin-chat-header-actions {
        justify-content: flex-start;
        white-space: normal;
    }

    .admin-chat-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-revision-form {
        grid-template-columns: 1fr;
    }

    .admin-revision-item {
        grid-template-columns: 1fr;
    }

    .modal-shell {
        padding: 18px;
    }

    .modal-header,
    .modal-actions,
    .operators-row-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .operators-actions-column {
        width: auto;
    }

    .message {
        max-width: 100%;
    }

    .message-attachment-body {
        grid-template-columns: 44px minmax(0, 1fr);
    }

    .message-attachment-link {
        grid-column: 1 / -1;
        justify-self: flex-start;
    }

    .attachment-gallery-dialog {
        grid-template-columns: 1fr;
        gap: 12px;
        width: calc(100vw - 16px);
        margin: 2vh auto;
        padding: 54px 8px 16px;
    }

    .attachment-gallery-figure {
        order: 1;
    }

    .attachment-gallery-nav {
        position: absolute;
        top: calc(50% - 24px);
        width: 48px;
        height: 48px;
    }

    .attachment-gallery-nav.prev {
        left: 8px;
    }

    .attachment-gallery-nav.next {
        right: 8px;
    }

    .attachment-gallery-image {
        max-height: calc(82vh - 120px);
    }

    .attachment-gallery-video {
        max-height: calc(82vh - 120px);
    }
}
