.panel-actions--account-home {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: flex-start;
    gap: 8px;
}

.panel-actions--account-home > .button-surface,
.panel-actions--account-home > .inline-form {
    flex: 1 1 0;
    min-width: 0;
}

.panel-card--account-home .panel-actions--account-home .button-surface,
.panel-card--auth .panel-actions--account-home .button-surface {
    min-height: 40px;
    padding: 0 10px;
    font-size: 0.86rem;
    line-height: 1.1;
    white-space: nowrap;
}

.button-surface--messages {
    position: relative;
}

.messages-badge {
    position: absolute;
    top: -8px;
    left: -8px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: #ff4a5a;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 10px 18px rgba(255, 74, 90, 0.34);
}

.panel-actions--account-home > .inline-form .button-surface {
    width: 100%;
    height: 100%;
}

.panel-actions--account-home .button-surface--admin-link {
    flex-basis: 0;
}

.contact-tools {
    display: grid;
    gap: 14px;
    margin-top: 16px;
}

.contact-tools__actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.contact-tool-form {
    margin: 0;
}

.contact-tool {
    width: 46px;
    height: 46px;
    border-radius: 4px;
    border: 1px solid rgba(52, 209, 255, 0.38);
    background: rgba(10, 24, 49, 0.78);
    color: #e9f4ff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 14px 28px rgba(5, 13, 29, 0.22);
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
    text-decoration: none;
    cursor: pointer;
    padding: 0;
}

.contact-tool:hover,
.contact-tool:focus-visible,
.contact-tool.is-active {
    transform: translateY(-1px);
    border-color: rgba(52, 209, 255, 0.7);
    box-shadow: 0 18px 30px rgba(5, 13, 29, 0.3);
}

.contact-tool.is-danger {
    border-color: rgba(255, 115, 115, 0.35);
}

.contact-tool.is-danger:hover,
.contact-tool.is-danger:focus-visible,
.contact-tool.is-danger.is-active {
    border-color: rgba(255, 115, 115, 0.68);
}

.contact-tool span {
    font-size: 1.08rem;
    line-height: 1;
}

.contact-panel {
    border: 1px solid rgba(97, 118, 160, 0.22);
    border-radius: 4px;
    background: rgba(8, 19, 39, 0.68);
    padding: 16px;
}

.contact-panel__form {
    display: grid;
    gap: 14px;
}

.contact-panel__note {
    border: 1px solid rgba(255, 196, 83, 0.24);
    border-radius: 4px;
    background: rgba(41, 31, 8, 0.45);
    color: #f7d57a;
    padding: 13px 15px;
    text-align: center;
}

.messages-layout {
    display: grid;
    min-height: calc(100dvh - var(--hero-shell-height, 190px) - 32px);
}

.messages-card {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    border-radius: 4px;
    overflow: hidden;
    min-height: calc(100dvh - var(--hero-shell-height, 190px) - 32px);
    max-height: calc(100dvh - var(--hero-shell-height, 190px) - 32px);
}

.messages-card__head--center {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 56px;
}

.messages-card__head--thread {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    min-height: 56px;
}

.messages-head-thread {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 0;
    text-align: center;
    grid-column: 2;
    justify-self: center;
}

.messages-head-back {
    width: 32px;
    height: 32px;
    border: 1px solid rgba(52, 209, 255, 0.36);
    background: rgba(10, 24, 49, 0.78);
    color: #eef6ff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.86rem;
    font-weight: 800;
    border-radius: 4px;
    transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.messages-head-back:hover,
.messages-head-back:focus-visible {
    border-color: rgba(52, 209, 255, 0.7);
    background: rgba(12, 31, 58, 0.95);
    transform: translateY(-1px);
}

.messages-card__body {
    display: grid;
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
    min-height: 0;
}

.messages-card__body--list-only {
    grid-template-columns: minmax(0, 520px);
    justify-content: center;
}

.messages-card__body--viewer-only {
    grid-template-columns: minmax(0, 1fr);
}

.messages-sidebar,
.messages-viewer {
    display: grid;
    gap: 16px;
    min-height: 0;
}

.messages-viewer--full {
    min-width: 0;
    height: 100%;
    overflow: hidden;
}

.messages-thread-list {
    display: grid;
    gap: 12px;
    overflow: auto;
    padding-left: 2px;
    min-height: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.messages-thread-card {
    display: grid;
    grid-template-columns: 62px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    border: 1px solid rgba(76, 98, 133, 0.26);
    border-radius: 4px;
    background: rgba(8, 19, 39, 0.62);
    padding: 11px 12px;
    text-decoration: none;
    color: #eef6ff;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.messages-thread-card:hover,
.messages-thread-card:focus-visible,
.messages-thread-card.is-active {
    transform: translateY(-1px);
    border-color: rgba(52, 209, 255, 0.5);
    box-shadow: 0 18px 32px rgba(5, 13, 29, 0.18);
}

.messages-thread-card__avatar img {
    width: 62px;
    height: 62px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid rgba(52, 209, 255, 0.28);
}

.messages-thread-card__copy {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.messages-thread-card__top,
.messages-thread-card__meta,
.messages-thread-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.messages-thread-card__top strong,
.messages-thread-head__identity strong {
    color: #f3f8ff;
    font-size: 1rem;
}

.messages-thread-card__top time,
.messages-thread-card__preview,
.messages-thread-head__identity a,
.message-bubble__head time,
.message-bubble__status {
    color: rgba(216, 230, 255, 0.72);
    font-size: 0.84rem;
}

.messages-thread-card__preview {
    margin: 0;
    line-height: 1.5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.messages-thread-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    padding: 5px 10px;
    font-size: 0.76rem;
    font-weight: 700;
    background: rgba(31, 48, 78, 0.88);
    color: #dbe8ff;
}

.messages-thread-card__meta {
    justify-content: flex-start;
}

.messages-thread-status.is-read {
    color: #54e59f;
}

.messages-thread-status.is-pending,
.messages-thread-status.is-unread {
    color: #ffd977;
}

.messages-composer,
.messages-conversation {
    display: grid;
    gap: 16px;
    border: 1px solid rgba(76, 98, 133, 0.24);
    border-radius: 4px;
    background: rgba(8, 19, 39, 0.58);
    padding: 10px;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.messages-conversation {
    grid-template-rows: minmax(0, 1fr) auto;
}

.messages-conversation__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(76, 98, 133, 0.18);
}

.messages-conversation__title-wrap {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.messages-conversation__title {
    color: #f3f8ff;
    font-size: 1.02rem;
    font-weight: 800;
    line-height: 1.2;
}

.messages-conversation__profile-link {
    color: rgba(216, 230, 255, 0.72);
    text-decoration: none;
    font-size: 0.84rem;
}

.messages-presence {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.03);
    flex: 0 0 auto;
}

.messages-presence--online {
    background: #39dc76;
}

.messages-presence--recent {
    background: #d8c247;
}

.messages-presence--offline {
    background: #7f8798;
}

.messages-thread-head__identity {
    display: flex;
    align-items: center;
    gap: 12px;
}

.messages-thread-head__identity img {
    width: 68px;
    height: 68px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid rgba(52, 209, 255, 0.26);
}

.messages-thread-head__identity a {
    text-decoration: none;
}

.messages-thread-head__meta {
    display: grid;
    gap: 8px;
    justify-items: end;
}

.messages-bubbles {
    display: grid;
    gap: 10px;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.messages-bubbles::-webkit-scrollbar,
.messages-thread-list::-webkit-scrollbar {
    display: none;
}

.message-bubble {
    display: grid;
    gap: 8px;
    width: min(100%, 88%);
    border-radius: 4px;
    border: 1px solid rgba(88, 111, 152, 0.2);
    background: rgba(14, 28, 54, 0.82);
    padding: 9px 10px;
    justify-self: start;
}

.message-bubble--mine {
    justify-self: end;
    background: linear-gradient(180deg, rgba(17, 45, 82, 0.92), rgba(12, 32, 62, 0.96));
    border-color: rgba(52, 209, 255, 0.28);
}

.message-bubble__head {
    display: block;
}

.message-bubble__identity {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #33d3ff;
    text-decoration: none;
    font-weight: 700;
}

.message-bubble__avatar {
    width: 34px;
    height: 34px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid rgba(52, 209, 255, 0.24);
    flex: 0 0 auto;
}

.message-bubble__name {
    color: #eaf4ff;
    font-size: 0.96rem;
    font-weight: 800;
    line-height: 1.2;
}

.message-bubble p {
    margin: 0;
    color: #eef6ff;
    font-size: 0.95rem;
    line-height: 1.75;
}

.message-bubble__foot {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    direction: ltr;
}

.message-bubble__time {
    color: rgba(216, 230, 255, 0.68);
    font-size: 0.76rem;
    line-height: 1.2;
}

.message-bubble__status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    color: #94a0b5;
    font-size: 0.86rem;
    font-weight: 800;
    line-height: 1;
}

.message-bubble__status.is-read {
    color: #54e59f;
}

.message-bubble__status.is-pending {
    color: #8d95a8;
}

.messages-reply-form {
    display: grid;
    grid-template-rows: auto auto;
    gap: 8px;
    min-height: 0;
    padding-top: 8px;
    border-top: 1px solid rgba(76, 98, 133, 0.16);
}

.messages-reply-form__label {
    color: #f0f6ff;
    font-size: 0.92rem;
    font-weight: 800;
    line-height: 1.2;
}

.messages-reply-form__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 140px;
    align-items: end;
    gap: 10px;
}

.messages-reply-form__field {
    margin: 0;
}

.messages-reply-form__field textarea {
    min-height: 88px;
    max-height: 140px;
    resize: none;
}

.messages-reply-form__field span {
    display: none;
}

.messages-reply-form__submit {
    min-height: 88px;
    width: 100%;
}

@media (max-width: 1024px) {
    .messages-card__body {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(220px, 34dvh) minmax(0, 1fr);
    }

    .messages-card__body--list-only {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
    }

    .messages-card__body--viewer-only {
        grid-template-rows: minmax(0, 1fr);
    }

    .messages-bubbles {
        overflow: auto;
    }
}

@media (max-width: 768px) {
    .panel-actions--account-home {
        display: flex;
        flex-wrap: nowrap;
        gap: 6px;
    }

    .panel-actions--account-home > .button-surface,
    .panel-actions--account-home > .inline-form {
        width: auto !important;
        min-width: 0;
        flex: 1 1 0;
    }

    .panel-actions--account-home > .inline-form {
        margin: 0;
    }

    .panel-actions--account-home .button-surface--admin-link {
        flex-basis: 0;
    }

    .panel-card--account-home .panel-actions--account-home .button-surface,
    .panel-card--auth .panel-actions--account-home .button-surface {
        min-height: 38px;
        padding: 0 6px;
        font-size: 0.76rem;
    }

    .contact-panel,
    .messages-composer,
    .messages-conversation {
        padding: 10px;
        border-radius: 4px;
    }

    .messages-tabs {
        width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .messages-head-actions {
        width: 100%;
        justify-content: stretch;
    }

    .messages-tab {
        min-width: 0;
        padding: 9px 12px;
        border-radius: 4px;
    }

    .messages-thread-card {
        grid-template-columns: 54px minmax(0, 1fr);
        padding: 12px;
        border-radius: 4px;
    }

    .messages-thread-card__avatar img {
        width: 54px;
        height: 54px;
        border-radius: 4px;
    }

    .messages-thread-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .messages-conversation__head {
        align-items: center;
        gap: 8px;
        padding-bottom: 8px;
    }

    .messages-card__head--thread {
        grid-template-columns: auto 1fr;
    }

    .messages-head-thread {
        justify-content: flex-start;
    }

    .messages-conversation__title {
        font-size: 0.96rem;
    }

    .messages-conversation__profile-link {
        font-size: 0.78rem;
    }

    .messages-thread-head__identity {
        width: 100%;
    }

    .messages-thread-head__identity img {
        width: 58px;
        height: 58px;
        border-radius: 4px;
    }

    .messages-thread-head__meta {
        width: 100%;
        justify-items: start;
    }

    .message-bubble {
        width: min(100%, 92%);
        padding: 8px 9px;
        border-radius: 4px;
    }

    .message-bubble__avatar {
        width: 32px;
        height: 32px;
    }

    .message-bubble__name {
        font-size: 0.9rem;
    }

    .message-bubble__time {
        font-size: 0.7rem;
    }

    .message-bubble p {
        font-size: 0.88rem;
        line-height: 1.65;
    }
}
