.inbox-page {
    display: grid;
    gap: 0.7rem;
    margin: -0.35rem -0.55rem -0.3rem;
}

/* Inbox title is now shown in the app topbar; keep h1 accessible but visually hidden */
.inbox-header {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.inbox-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.inbox-header-actions label {
    font-size: 0.85rem;
    color: var(--muted-strong);
}

.inbox-shell {
    display: grid;
    grid-template-columns: minmax(220px, 270px) minmax(300px, 360px) minmax(0, 1fr);
    height: clamp(600px, calc(100dvh - 68px), 1080px);
    min-height: 0;
    overflow: hidden;
}

.inbox-shell.is-upgrade-locked {
    opacity: 0.55;
    filter: grayscale(0.24);
    pointer-events: none;
}

.inbox-upgrade-banner {
    border: 1px solid rgba(101, 163, 121, 0.95);
    border-radius: 0.95rem;
    padding: 0.95rem 1rem;
    background: linear-gradient(180deg, #edf9f0 0%, #e3f5e9 100%);
    box-shadow: 0 8px 20px rgba(35, 87, 51, 0.12);
    display: grid;
    gap: 0.45rem;
    justify-items: start;
}

.inbox-upgrade-banner h2 {
    margin: 0;
    font-size: 1.05rem;
    color: #1f5a2f;
}

.inbox-upgrade-banner p {
    margin: 0;
    color: #244d30;
}

.inbox-mailboxes {
    min-height: 0;
    overflow: auto;
    display: grid;
    align-content: start;
    gap: 0.75rem;
    padding: 0.75rem;
    border-right: 1px solid var(--panel-border);
    background:
        linear-gradient(180deg, rgba(243, 247, 255, 0.97), rgba(236, 242, 251, 0.97));
}

.inbox-mailbox-section {
    display: grid;
    gap: 0.32rem;
    padding: 0.55rem;
    border: 1px solid rgba(164, 180, 202, 0.7);
    border-radius: 0.92rem;
    background: rgba(255, 255, 255, 0.9);
}

.inbox-mailbox-section-personal {
    border-color: rgba(124, 155, 194, 0.85);
    box-shadow: inset 0 0 0 1px rgba(174, 198, 229, 0.35);
}

.inbox-mailbox-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.1rem;
}

.inbox-mailbox-section-header strong {
    font-size: 0.8rem;
    color: #324a67;
    letter-spacing: 0.01em;
}

.inbox-mailbox-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    border: 1px solid transparent;
    border-radius: 0.65rem;
    padding: 0.44rem 0.5rem;
    background: transparent;
    color: #243a56;
    text-align: left;
    transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.inbox-mailbox-item i {
    color: #4a6586;
    font-size: 0.9rem;
}

.inbox-mailbox-item:hover:not(:disabled) {
    background: rgba(236, 245, 255, 0.95);
    border-color: rgba(146, 175, 208, 0.85);
}

.inbox-mailbox-item.is-active {
    background: linear-gradient(180deg, #dcecff 0%, #d0e4ff 100%);
    border-color: rgba(90, 128, 174, 0.9);
    box-shadow: inset 0 0 0 1px rgba(109, 148, 194, 0.35);
    color: #1a3555;
    font-weight: 600;
}

.inbox-mailbox-item.is-active i {
    color: #254f85;
}

.inbox-mailbox-item-label {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inbox-mailbox-item-count {
    margin-left: auto;
    font-size: 0.75rem;
    line-height: 1;
    color: #5e728b;
    font-weight: 500;
    min-width: 1.5rem;
    text-align: right;
}

.inbox-mailbox-item.is-active .inbox-mailbox-item-count {
    color: #2d4d76;
}

.inbox-queue {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    min-height: 0;
    border-right: 1px solid var(--panel-border);
    background:
        linear-gradient(180deg, rgba(236, 240, 247, 0.97), rgba(229, 234, 243, 0.97));
}

.inbox-queue-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1rem 0.85rem;
    border-bottom: 1px solid var(--panel-border);
    background: rgba(248, 250, 255, 0.82);
    backdrop-filter: blur(4px);
}

.inbox-queue-header-main {
    display: grid;
    min-width: 0;
}

.inbox-queue-header-main strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inbox-queue-header-main small {
    color: #5e728b;
    font-size: 0.74rem;
    letter-spacing: 0.01em;
}

.inbox-queue-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.inbox-mailboxes-toggle {
    display: none;
    width: 2rem;
    height: 2rem;
    padding: 0;
    align-items: center;
    justify-content: center;
}

.inbox-mailboxes-backdrop {
    display: none;
}

.inbox-queue-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid rgba(170, 183, 200, 0.6);
    background: rgba(244, 248, 255, 0.88);
}

.inbox-queue-search {
    grid-column: 1 / -1;
    position: relative;
}

.inbox-queue-search .form-control {
    min-width: 0;
    height: 2.2rem;
    font-size: 0.84rem;
    padding-right: 2.2rem;
}

.inbox-queue-search-clear {
    position: absolute;
    top: 50%;
    right: 0.35rem;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: #5f738d;
    width: 1.65rem;
    height: 1.65rem;
    border-radius: 0.45rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.inbox-queue-search-clear:hover {
    background: rgba(226, 236, 248, 0.9);
    color: #2b4a6f;
}

.inbox-queue-search-clear i {
    font-size: 0.74rem;
    line-height: 1;
}

.inbox-queue-toolbar .form-select {
    min-width: 0;
    height: 2.2rem;
    font-size: 0.84rem;
}

.inbox-queue-refresh {
    min-width: 2.2rem;
    height: 2.2rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.inbox-queue-list {
    overflow: auto;
    padding: 0.75rem;
    display: grid;
    gap: 0.65rem;
    align-content: start;
    grid-auto-rows: max-content;
}

.inbox-queue-item {
    border: 1px solid var(--line-soft);
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.96);
    text-align: left;
    padding: 0.65rem 0.75rem;
    display: grid;
    gap: 0.32rem;
    cursor: pointer;
    min-height: 0;
    height: auto;
    transition: transform 120ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.inbox-queue-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(12, 27, 48, 0.1);
}

.inbox-queue-item.is-active {
    border-color: #4f647f;
    box-shadow: 0 0 0 2px rgba(134, 157, 186, 0.35), 0 10px 22px rgba(15, 41, 72, 0.12);
}

.inbox-queue-item.has-unread {
    border-color: #3f5f88;
    background: linear-gradient(180deg, #f3f7ff 0%, #eaf1ff 100%);
    box-shadow: inset 3px 0 0 #2f5f97, 0 0 0 1px rgba(95, 120, 150, 0.3);
}

.inbox-queue-item.is-incoming {
    animation: inboxQueueItemIn 560ms cubic-bezier(0.22, 1, 0.36, 1);
}

.inbox-queue-item-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}

.inbox-queue-item-tags {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.inbox-unread-badge {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 999px;
    padding: 0.12rem 0.48rem;
    color: #ffffff;
    background: #23548a;
    border: 1px solid #1d4673;
    font-weight: 700;
}

.inbox-status-badge {
    font-size: 0.73rem;
    color: #26405f;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 999px;
    padding: 0.16rem 0.52rem;
    white-space: nowrap;
    border: 1px solid transparent;
}

.inbox-status-badge.is-open {
    color: #0b5b48;
    background: rgba(205, 240, 227, 0.95);
    border-color: rgba(132, 195, 172, 0.95);
}

.inbox-status-badge.is-in-progress {
    color: #5b3d00;
    background: rgba(255, 235, 192, 0.95);
    border-color: rgba(219, 182, 111, 0.95);
}

.inbox-status-badge.is-snoozed {
    color: #4d2f7e;
    background: rgba(229, 216, 255, 0.95);
    border-color: rgba(183, 151, 233, 0.95);
}

.inbox-status-badge.is-closed {
    color: #2f3c4d;
    background: rgba(226, 231, 237, 0.95);
    border-color: rgba(176, 186, 198, 0.95);
}

.inbox-queue-preview {
    margin: 0;
    color: #2f3f54;
    font-size: 0.84rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.inbox-queue-item.has-unread .inbox-queue-customer-name,
.inbox-queue-item.has-unread .inbox-queue-preview,
.inbox-queue-item.has-unread .inbox-queue-meta {
    font-weight: 700;
    color: #172a44;
}

.inbox-queue-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    color: #5a6b7f;
    font-size: 0.72rem;
}

.inbox-queue-assignee {
    margin-left: auto;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 999px;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(220, 232, 248, 0.92);
    border: 1px solid rgba(149, 171, 198, 0.82);
    color: #234568;
    flex: 0 0 auto;
}

.inbox-queue-assignee img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.inbox-queue-assignee-initial {
    font-size: 0.64rem;
    line-height: 1;
    font-weight: 700;
}

.inbox-unread-dot {
    width: 0.56rem;
    height: 0.56rem;
    border-radius: 999px;
    background: #1f4f86;
    box-shadow: 0 0 0 2px rgba(31, 79, 134, 0.22);
    margin-right: auto;
    margin-top: 0.22rem;
}

.inbox-conversation {
    min-height: 0;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(249, 250, 252, 0.99));
}

.inbox-conversation-backdrop {
    display: none;
}

.inbox-conversation-layout {
    height: 100%;
    min-height: 0;
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 0px;
    transition: grid-template-columns 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.inbox-conversation-layout.is-drawer-open {
    grid-template-columns: minmax(0, 1fr) 300px;
}

.inbox-conversation-main {
    position: relative;
    min-height: 0;
    overflow: hidden;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
}

.inbox-assignment-drawer {
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    border-left: 1px solid var(--panel-border);
    background: linear-gradient(180deg, rgba(246, 249, 254, 0.96), rgba(239, 244, 251, 0.96));
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
}

.inbox-assignment-drawer.is-open {
    opacity: 1;
    pointer-events: auto;
}

.inbox-assignment-drawer-header {
    padding: 0.8rem 0.72rem;
    border-bottom: 1px solid rgba(171, 185, 204, 0.6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    min-height: 0;
}

.inbox-assignment-drawer-header strong {
    font-size: 0.88rem;
    color: #20344e;
}

.inbox-assignment-toggle {
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.96);
    color: #254365;
    border-radius: 0.58rem;
    padding: 0;
}

.inbox-assignment-toggle:hover,
.inbox-assignment-toggle:focus-visible {
    border-color: rgba(124, 155, 194, 0.95);
    background: rgba(238, 246, 255, 0.95);
}

.inbox-assignment-drawer-close {
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.58rem;
    padding: 0;
    border: 1px solid rgba(151, 171, 198, 0.95);
    background: rgba(255, 255, 255, 0.96);
    color: #254365;
}

.inbox-assignment-drawer-close:hover {
    border-color: rgba(124, 155, 194, 0.95);
    background: rgba(238, 246, 255, 0.95);
}

.inbox-assignment-backdrop {
    display: none;
    border: 0;
    margin: 0;
    padding: 0;
    background: transparent;
}

.inbox-assignment-backdrop {
    animation: inboxBackdropIn 160ms ease-out;
}

.inbox-assignment-drawer-body {
    padding: 0.85rem 0.72rem;
    display: grid;
    gap: 0.42rem;
    align-content: start;
    overflow: auto;
}

.inbox-assignment-drawer-body .form-label {
    margin-bottom: 0.1rem;
}

.inbox-contact-panel {
    border: 1px solid rgba(178, 196, 219, 0.78);
    border-radius: 0.7rem;
    padding: 0.62rem;
    background: rgba(255, 255, 255, 0.92);
    display: grid;
    gap: 0.55rem;
}

.inbox-contact-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.inbox-contact-primary {
    display: grid;
    gap: 0.1rem;
    padding: 0.45rem 0.55rem;
    border-radius: 0.58rem;
    background: rgba(224, 239, 255, 0.68);
    border: 1px solid rgba(156, 187, 221, 0.75);
    font-size: 0.79rem;
}

.inbox-contact-primary-label {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    background: rgba(77, 123, 179, 0.2);
    color: #2d507e;
    font-size: 0.67rem;
    font-weight: 700;
}

.inbox-contact-primary-actions {
    margin-top: 0.35rem;
    display: flex;
    justify-content: flex-end;
}

.inbox-contact-unlink-btn {
    width: 1.85rem;
    height: 1.85rem;
    min-width: 1.85rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.inbox-contact-list {
    display: grid;
    gap: 0.45rem;
}

.inbox-contact-item {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 0.5rem;
    border: 1px solid rgba(188, 204, 224, 0.8);
    border-radius: 0.58rem;
    padding: 0.45rem 0.52rem;
    background: rgba(255, 255, 255, 0.96);
}

.inbox-contact-item.is-primary {
    border-color: rgba(120, 163, 210, 0.95);
    background: rgba(237, 246, 255, 0.9);
}

.inbox-contact-item-main {
    display: grid;
    gap: 0.05rem;
    min-width: 0;
}

.inbox-contact-item-main strong {
    font-size: 0.81rem;
    color: #1e3b5d;
}

.inbox-contact-item-main span {
    font-size: 0.75rem;
    color: #5f7592;
    word-break: break-word;
}

.inbox-contact-item-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.inbox-contact-search-results {
    margin-top: 0.45rem;
    display: grid;
    gap: 0.35rem;
    max-height: 190px;
    overflow: auto;
}

.inbox-contact-search-result {
    width: 100%;
    text-align: left;
    border: 1px solid rgba(184, 200, 221, 0.78);
    border-radius: 0.52rem;
    background: rgba(248, 251, 255, 0.95);
    padding: 0.4rem 0.48rem;
    display: grid;
    gap: 0.06rem;
}

.inbox-contact-search-result strong {
    font-size: 0.79rem;
    color: #234362;
}

.inbox-contact-search-result span {
    font-size: 0.73rem;
    color: #667f9f;
}

.inbox-contact-create-link {
    margin-top: 0.35rem;
    border: 0;
    background: transparent;
    color: #3b5f87;
    font-size: 0.74rem;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
    width: fit-content;
}

.inbox-contact-create-link:hover:not(:disabled) {
    color: #264a72;
}

.inbox-contact-create-link:disabled {
    color: #7a8ea8;
    text-decoration: none;
}

.inbox-conversation-header {
    position: relative;
    z-index: 8;
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 1rem;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--panel-border);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
}

.inbox-conversation-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

.inbox-mobile-conversation-close {
    display: none;
}

.inbox-conversation-actions-primary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.inbox-conversation-actions-secondary {
    display: flex;
    align-items: center;
    padding-left: 0.65rem;
    margin-left: 0.12rem;
    border-left: 1px solid rgba(162, 177, 198, 0.7);
}

.inbox-conversation-actions-secondary .inbox-assignment-toggle {
    width: 2.65rem;
    height: 2.65rem;
    min-width: 2.65rem;
    border-radius: 0.72rem;
    align-self: center;
}

.inbox-conversation-actions-secondary .inbox-assignment-toggle i {
    display: block;
    line-height: 1;
    transform: translateY(1px);
}

.inbox-conversation-action-icon {
    width: 2.65rem;
    height: 2.65rem;
    min-width: 2.65rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.72rem;
    padding: 0;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.96);
    color: #2a496d;
}

.inbox-conversation-action-icon i {
    font-size: 1rem;
    line-height: 1;
}

.inbox-conversation-action-icon:hover:not(:disabled),
.inbox-conversation-action-icon:focus-visible:not(:disabled) {
    border-color: rgba(124, 155, 194, 0.95);
    background: rgba(238, 246, 255, 0.95);
}

.inbox-conversation-action-icon:disabled {
    opacity: 0.58;
}

.inbox-conversation-action-close {
    color: #6f3340;
}

.inbox-conversation-action-close:hover:not(:disabled) {
    border-color: rgba(193, 126, 143, 0.9);
    background: rgba(252, 237, 241, 0.95);
}

.inbox-conversation-actions-menu {
    position: relative;
}

.inbox-conversation-menu-trigger {
    color: #59739a;
}

.inbox-conversation-menu-trigger i {
    font-size: 0.86rem;
}

.inbox-conversation-menu-trigger.is-active {
    border-color: rgba(124, 155, 194, 0.95);
    background: rgba(238, 246, 255, 0.95);
}

.inbox-conversation-menu-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    margin: 0;
    padding: 0;
    background: transparent;
    z-index: 7;
}

.inbox-conversation-menu {
    position: absolute;
    top: calc(100% + 0.34rem);
    right: 0;
    min-width: 10.8rem;
    border: 1px solid rgba(156, 177, 203, 0.86);
    border-radius: 0.62rem;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 10px 24px rgba(14, 31, 54, 0.18);
    padding: 0.3rem;
    z-index: 9;
}

.inbox-conversation-menu-item {
    width: 100%;
    border: 0;
    border-radius: 0.5rem;
    background: transparent;
    color: #2a496d;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.42rem 0.5rem;
    font-size: 0.84rem;
    text-align: left;
}

.inbox-conversation-menu-item i {
    color: #5478a2;
    font-size: 0.88rem;
}

.inbox-conversation-menu-item:hover,
.inbox-conversation-menu-item:focus-visible {
    background: rgba(236, 245, 255, 0.95);
    outline: none;
}

.inbox-snooze-presets {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.55rem;
}

.inbox-snooze-preset {
    min-height: 2.35rem;
    border: 1px solid rgba(167, 183, 205, 0.78);
    border-radius: 0.62rem;
    background: rgba(249, 252, 255, 0.9);
    color: #2a496d;
    font-size: 0.86rem;
    font-weight: 600;
    padding: 0.45rem 0.5rem;
}

.inbox-snooze-preset:hover:not(:disabled),
.inbox-snooze-preset:focus-visible:not(:disabled) {
    border-color: rgba(124, 155, 194, 0.95);
    background: rgba(238, 246, 255, 0.95);
}

.inbox-snooze-preset.is-active {
    border-color: rgba(76, 120, 168, 0.95);
    background: rgba(225, 238, 255, 0.96);
    color: #1f3d61;
}

.inbox-snooze-preset:disabled {
    opacity: 0.65;
}

.inbox-snooze-custom {
    margin-top: 0.9rem;
}

.inbox-thread-messages {
    overflow: auto;
    padding: 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background:
        radial-gradient(circle at 24px 24px, rgba(191, 201, 217, 0.17) 1.4px, transparent 0) 0 0 / 34px 34px,
        linear-gradient(180deg, rgba(250, 252, 255, 0.98), rgba(245, 247, 251, 0.98));
}

.inbox-message-row {
    display: flex;
    align-items: flex-end;
    gap: 0.55rem;
    max-width: min(86%, 770px);
}

.inbox-message-row.customer {
    align-self: flex-start;
}

.inbox-message-row.operator,
.inbox-message-row.assistant,
.inbox-message-row.system {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.inbox-message-row.internal-note {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.inbox-event-row {
    display: flex;
    justify-content: flex-end;
    width: 100%;
}

.inbox-event-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    max-width: min(92%, 700px);
    color: #5f7490;
    padding: 0;
    font-size: 0.73rem;
    line-height: 1.3;
    text-align: right;
}

.inbox-event-item i {
    color: #6683a6;
    font-size: 0.74rem;
    flex: 0 0 auto;
}

.inbox-event-item span {
    overflow-wrap: anywhere;
}

.inbox-event-item time {
    color: #7a8da7;
    font-size: 0.69rem;
    margin-left: 0.2rem;
    white-space: nowrap;
}

.inbox-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    flex: 0 0 32px;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.76rem;
    font-weight: 700;
    color: #1f3653;
    background: linear-gradient(180deg, #f4f7fc, #e3ebf7);
    border: 1px solid rgba(149, 171, 199, 0.95);
    box-shadow: 0 2px 8px rgba(17, 37, 61, 0.13);
}

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

.inbox-message-row.operator .inbox-message-avatar {
    color: #edf4ff;
    background: linear-gradient(165deg, #32557d, #284566);
    border-color: rgba(60, 95, 136, 0.95);
}

.inbox-message-row.internal-note .inbox-message-avatar {
    color: #5d4513;
    background: linear-gradient(165deg, #f7e8b4, #eed47b);
    border-color: rgba(198, 162, 71, 0.9);
}

.inbox-message {
    position: relative;
    border-radius: 1rem;
    border: 1px solid var(--line-soft);
    padding: 0.7rem 0.8rem;
    display: grid;
    gap: 0.4rem;
    box-shadow: 0 4px 12px rgba(17, 38, 66, 0.07);
}

.inbox-message.customer {
    align-self: flex-start;
    background: #fff8ef;
    border-color: rgba(229, 196, 142, 0.9);
    border-bottom-left-radius: 0.4rem;
}

.inbox-message.customer::after {
    content: "";
    position: absolute;
    left: -6px;
    bottom: 12px;
    width: 10px;
    height: 10px;
    background: #fff8ef;
    border-left: 1px solid rgba(229, 196, 142, 0.9);
    border-bottom: 1px solid rgba(229, 196, 142, 0.9);
    transform: rotate(45deg);
}

.inbox-message.operator {
    align-self: flex-end;
    background: linear-gradient(165deg, #2f4f75, #284566);
    border-color: rgba(48, 77, 112, 0.95);
    color: #f4f8ff;
    border-bottom-right-radius: 0.4rem;
}

.inbox-message.internal-note {
    align-self: flex-end;
    background: linear-gradient(165deg, #fff6d7, #f7e2a3);
    border-color: rgba(202, 166, 73, 0.92);
    color: #4a3610;
    border-bottom-right-radius: 0.4rem;
}

.inbox-message.operator::after {
    content: "";
    position: absolute;
    right: -6px;
    bottom: 12px;
    width: 10px;
    height: 10px;
    background: #2d4b6f;
    border-right: 1px solid rgba(48, 77, 112, 0.95);
    border-bottom: 1px solid rgba(48, 77, 112, 0.95);
    transform: rotate(-45deg);
}

.inbox-message.internal-note::after {
    content: "";
    position: absolute;
    right: -6px;
    bottom: 12px;
    width: 10px;
    height: 10px;
    background: #f7e2a3;
    border-right: 1px solid rgba(202, 166, 73, 0.92);
    border-bottom: 1px solid rgba(202, 166, 73, 0.92);
    transform: rotate(-45deg);
}

.inbox-message.system {
    align-self: flex-end;
    background: #eef2f7;
    border-color: rgba(168, 181, 197, 0.9);
    color: #223247;
    border-bottom-right-radius: 0.4rem;
}

.inbox-message.system::after {
    content: "";
    position: absolute;
    right: -6px;
    bottom: 12px;
    width: 10px;
    height: 10px;
    background: #eef2f7;
    border-right: 1px solid rgba(168, 181, 197, 0.9);
    border-bottom: 1px solid rgba(168, 181, 197, 0.9);
    transform: rotate(-45deg);
}

.inbox-message.assistant {
    align-self: flex-end;
    background: #eef2f7;
    border-color: rgba(168, 181, 197, 0.9);
    color: #223247;
    border-bottom-right-radius: 0.4rem;
}

.inbox-message.assistant::after {
    content: "";
    position: absolute;
    right: -6px;
    bottom: 12px;
    width: 10px;
    height: 10px;
    background: #eef2f7;
    border-right: 1px solid rgba(168, 181, 197, 0.9);
    border-bottom: 1px solid rgba(168, 181, 197, 0.9);
    transform: rotate(-45deg);
}

.inbox-message header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    font-size: 0.77rem;
    color: var(--muted-strong);
}

.inbox-message.operator header {
    color: rgba(232, 239, 250, 0.92);
}

.inbox-message-header-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.inbox-message-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.14rem 0.42rem;
    border-radius: 999px;
    background: rgba(108, 82, 20, 0.12);
    color: #785919;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;
}

.inbox-message p {
    margin: 0;
    line-height: 1.45;
    white-space: pre-wrap;
}

.inbox-message .inbox-md-paragraph {
    margin: 0;
    line-height: 1.45;
    white-space: normal;
}

.inbox-message .inbox-md-paragraph + .inbox-md-paragraph,
.inbox-message .inbox-md-paragraph + .inbox-md-list,
.inbox-message .inbox-md-list + .inbox-md-paragraph,
.inbox-message .inbox-md-list + .inbox-md-list {
    margin-top: 0.44rem;
}

.inbox-message .inbox-md-list {
    margin: 0;
    padding-inline-start: 1.2rem;
}

.inbox-message .inbox-md-list li + li {
    margin-top: 0.2rem;
}

.inbox-message a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.inbox-message code {
    display: inline-block;
    padding: 0.03rem 0.3rem;
    border-radius: 0.35rem;
    background: rgba(15, 29, 48, 0.1);
    font-size: 0.82em;
}

.inbox-reply-box {
    position: relative;
    border-top: 1px solid var(--panel-border);
    padding: 0.9rem 1.1rem 1rem;
    display: grid;
    gap: 0.55rem;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(3px);
}

.inbox-composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 0.38rem;
    padding: 0.34rem;
    border: 1px solid rgba(168, 182, 201, 0.95);
    border-radius: 0.9rem;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.inbox-composer-head {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.04rem 0.08rem 0;
}

.inbox-markdown-toolbar {
    display: flex;
    align-items: center;
    gap: 0.26rem;
    min-width: 0;
}

.inbox-internal-note-option {
    display: inline-flex;
    align-items: center;
    gap: 0.42rem;
    flex: 0 0 auto;
    padding: 0.22rem 0.5rem;
    border: 1px solid rgba(185, 196, 210, 0.95);
    border-radius: 999px;
    background: rgba(246, 249, 253, 0.96);
    color: #47617d;
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.1;
    cursor: pointer;
    user-select: none;
}

.inbox-internal-note-option:hover {
    background: rgba(239, 245, 251, 0.98);
    border-color: rgba(156, 176, 199, 0.96);
}

.inbox-internal-note-option input {
    width: 0.82rem;
    height: 0.82rem;
    margin: 0;
    accent-color: #406489;
}

.inbox-internal-note-option span {
    white-space: nowrap;
}

.inbox-internal-note-option:has(input:checked) {
    background: rgba(255, 244, 208, 0.92);
    border-color: rgba(202, 166, 73, 0.92);
    color: #6e5317;
}

.inbox-markdown-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    border: 1px solid rgba(167, 182, 201, 0.95);
    border-radius: 0.56rem;
    background: rgba(247, 251, 255, 0.98);
    color: #28415f;
}

.inbox-markdown-btn:hover:not(:disabled) {
    background: rgba(232, 241, 252, 0.95);
    border-color: rgba(125, 157, 194, 0.95);
}

.inbox-markdown-btn:disabled {
    opacity: 0.55;
}

.inbox-composer:focus-within {
    border-color: #5d86b5;
    box-shadow: 0 0 0 2px rgba(126, 167, 210, 0.25);
}

.inbox-reply-editor {
    flex: 1 1 auto;
    min-height: 2.65rem;
    max-height: 7.4rem;
    overflow-y: auto;
    margin: 0;
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 0.42rem 0.5rem;
    white-space: pre-wrap;
    line-height: 1.45;
}

.inbox-reply-editor:focus {
    box-shadow: none !important;
    outline: none;
}

.inbox-reply-editor:empty::before {
    content: attr(data-placeholder);
    color: #7a8da6;
    pointer-events: none;
}

.inbox-reply-editor p {
    margin: 0;
}

.inbox-reply-editor ul,
.inbox-reply-editor ol {
    margin: 0.18rem 0;
    padding-inline-start: 1.2rem;
}

.inbox-reply-editor li + li {
    margin-top: 0.15rem;
}

.inbox-mention-dropdown {
    position: absolute;
    bottom: 100%;
    left: 1.1rem;
    right: 1.1rem;
    margin-bottom: 0.35rem;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.15);
    z-index: 50;
    overflow: hidden;
    max-height: 14rem;
    overflow-y: auto;
}

.inbox-mention-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: none;
    border: 0;
    text-align: left;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--bs-body-color);
    transition: background-color 0.1s;
}

.inbox-mention-option:hover,
.inbox-mention-option:focus {
    background-color: var(--bs-tertiary-bg, #f8f9fa);
    outline: none;
}

.inbox-mention-option .bi {
    flex-shrink: 0;
    color: var(--bs-secondary-color, #6c757d);
}

.inbox-mention-handle {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--bs-secondary-color, #6c757d);
}

.inbox-send-split {
    position: relative;
    display: flex;
    align-items: stretch;
    align-self: end;
    flex: 0 0 auto;
    z-index: 31;
}

.inbox-send-backdrop {
    position: fixed;
    inset: 0;
    border: 0;
    margin: 0;
    padding: 0;
    background: transparent;
    z-index: 30;
}

.inbox-send-main {
    min-height: 2.55rem;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.inbox-send-toggle {
    min-height: 2.55rem;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    min-width: 2.2rem;
    padding-inline: 0.58rem;
    border-left: 1px solid rgba(255, 255, 255, 0.35);
}

.inbox-send-menu {
    position: absolute;
    bottom: calc(100% + 0.4rem);
    right: 0;
    min-width: 13.6rem;
    display: grid;
    gap: 0.2rem;
    padding: 0.3rem;
    border: 1px solid var(--panel-border);
    border-radius: 0.8rem;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 14px 28px rgba(12, 26, 44, 0.18);
    z-index: 35;
}

.inbox-send-menu-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.46rem 0.56rem;
    border: 1px solid transparent;
    border-radius: 0.56rem;
    background: transparent;
    color: #1c2e43;
    font-size: 0.86rem;
    text-align: left;
}

.inbox-send-menu-item:hover {
    background: rgba(228, 237, 249, 0.85);
    border-color: rgba(170, 190, 214, 0.9);
}

.inbox-empty {
    padding: 1.15rem;
    color: var(--muted-strong);
}

.inbox-empty-conversation {
    display: grid;
    place-items: center;
    text-align: center;
    color: #5b6f87;
    background:
        linear-gradient(180deg, rgba(251, 253, 255, 0.96), rgba(245, 250, 255, 0.96));
}

@media (max-width: 1100px) {
    .inbox-page {
        margin: 0;
        min-height: 0;
    }

    .inbox-shell {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr);
        height: clamp(520px, calc(100dvh - 100px), 960px);
        min-height: 430px;
        position: relative;
        overflow: hidden;
    }

    .inbox-mailboxes {
        position: absolute;
        inset: 0 auto 0 0;
        width: min(86vw, 300px);
        max-height: none;
        border-right: 1px solid var(--panel-border);
        border-bottom: 0;
        z-index: 18;
        transform: translateX(-104%);
        opacity: 0;
        pointer-events: none;
        transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 160ms ease;
        box-shadow: 12px 0 26px rgba(12, 26, 44, 0.2);
    }

    .inbox-shell.is-mailbox-open .inbox-mailboxes {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
    }

    .inbox-mailboxes-backdrop {
        display: block;
        position: absolute;
        inset: 0;
        border: 0;
        margin: 0;
        padding: 0;
        background: rgba(8, 18, 30, 0.28);
        z-index: 17;
        opacity: 0;
        pointer-events: none;
        transition: opacity 160ms ease;
    }

    .inbox-shell.is-mailbox-open .inbox-mailboxes-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .inbox-queue {
        height: 100%;
        max-height: none;
        min-height: 0;
        border-right: 0;
        border-bottom: 0;
    }

    .inbox-queue-list {
        min-height: 0;
    }

    .inbox-mailboxes-toggle {
        display: inline-flex;
    }

    .inbox-conversation {
        position: absolute;
        inset: 0 0 0 auto;
        width: 100%;
        border-left: 1px solid var(--panel-border);
        transform: translateX(102%);
        opacity: 0;
        pointer-events: none;
        z-index: 26;
        transition: transform 240ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 180ms ease;
        box-shadow: -14px 0 30px rgba(12, 26, 44, 0.2);
    }

    .inbox-shell.is-conversation-open .inbox-conversation {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
    }

    .inbox-conversation-backdrop {
        display: block;
        position: absolute;
        inset: 0;
        border: 0;
        margin: 0;
        padding: 0;
        background: rgba(8, 18, 30, 0.28);
        z-index: 25;
        opacity: 0;
        pointer-events: none;
        transition: opacity 160ms ease;
    }

    .inbox-shell.is-conversation-open .inbox-conversation-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .inbox-mobile-conversation-close {
        display: inline-flex;
        width: 2.2rem;
        height: 2.2rem;
        align-items: center;
        justify-content: center;
        padding: 0;
    }

    .inbox-message {
        max-width: 92%;
    }

    .inbox-message-row {
        max-width: 100%;
    }
}

@media (max-width: 700px) {
    .inbox-header {
        align-items: start;
        flex-direction: column;
    }

    .inbox-header-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .inbox-composer {
        flex-direction: column;
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        align-items: stretch;
    }

    .inbox-composer-head {
        flex-wrap: wrap;
    }

    .inbox-send-split {
        align-self: flex-end;
    }

    .inbox-snooze-presets {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .inbox-conversation-layout,
    .inbox-conversation-layout.is-drawer-open {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr);
    }

    .inbox-assignment-drawer {
        position: absolute;
        inset: 0 0 0 auto;
        width: min(90vw, 340px);
        border-left: 1px solid var(--panel-border);
        border-top: 0;
        z-index: 22;
        box-shadow: -12px 0 28px rgba(12, 26, 44, 0.24);
        transform: translateX(100%);
        transition: transform 240ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 200ms ease;
    }

    .inbox-assignment-drawer.is-open {
        transform: translateX(0);
    }

    .inbox-assignment-backdrop {
        display: block;
        position: absolute;
        inset: 0;
        background: rgba(8, 18, 30, 0.28);
        z-index: 21;
    }

    .inbox-conversation-actions {
        flex-wrap: nowrap;
        justify-content: end;
    }

    .inbox-conversation-actions-secondary {
        padding-left: 0.45rem;
        margin-left: 0.05rem;
    }

    .inbox-assignment-toggle {
        min-width: 2.35rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .inbox-assignment-drawer,
    .inbox-assignment-backdrop,
    .inbox-queue-item.is-incoming,
    .inbox-conversation-layout {
        animation: none;
        transition: none;
    }
}


@keyframes inboxBackdropIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes inboxQueueItemIn {
    from {
        opacity: 0.35;
        transform: translateY(-14px) scale(0.985);
        box-shadow: 0 10px 24px rgba(22, 57, 95, 0.18);
    }

    55% {
        opacity: 1;
        transform: translateY(0) scale(1.004);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        box-shadow: none;
    }
}

/* Typing indicator */
.inbox-typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: var(--inbox-msg-customer-bg, #f0f0f0);
    border-radius: 16px;
    margin: 4px 0;
}

.inbox-typing-indicator span {
    display: block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--inbox-msg-customer-text, #555);
    opacity: 0.4;
    animation: typingBounce 1.2s infinite ease-in-out;
}

.inbox-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.inbox-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(1); opacity: 0.4; }
    40%            { transform: scale(1.35); opacity: 1; }
}
