/* MSX 聊天插件前台样式，跟随当前主题变量。 */

.msx-chat-shell {
    --msx-chat-head-height: 34px;
    --msx-chat-control-size: 24px;
    --msx-chat-row-height: 44px;

    display: grid;
    width: 100%;
    height: min(820px, calc(100vh - 180px));
    height: clamp(560px, calc(100dvh - 180px), 820px);
    min-height: 0;
    max-height: calc(100dvh - 144px);
}

.page-shell:has(> .msx-chat-shell) {
    width: min(1280px, calc(100% - 32px));
    padding-top: 16px;
    padding-bottom: 16px;
}

.msx-chat-workspace {
    grid-template-columns: minmax(256px, 312px) minmax(0, 1fr);
    overflow: hidden;
    align-items: stretch;
    border: 1px solid var(--color-hairline);
    border-radius: var(--radius-md);
    background: var(--color-surface);
}

.msx-chat-thread,
.msx-chat-sidebar {
    min-height: 0;
    background: var(--color-surface);
}

.msx-chat-sidebar {
    display: grid;
    position: relative;
    grid-template-columns: 64px minmax(0, 1fr);
    min-height: 0;
    border-right: 1px solid var(--color-hairline);
    background: color-mix(in srgb, var(--color-surface-strong) 36%, var(--color-surface));
}

.msx-chat-sidebar-panel {
    display: grid;
    position: relative;
    grid-template-rows: auto minmax(0, 1fr);
    min-width: 0;
    min-height: 0;
    background: color-mix(in srgb, var(--color-surface-strong) 36%, var(--color-surface));
}

.msx-chat-sidebar-head {
    display: grid;
    position: relative;
    box-sizing: border-box;
    grid-template-columns: minmax(0, 1fr) var(--msx-chat-control-size);
    align-items: center;
    gap: 6px;
    height: var(--msx-chat-head-height);
    min-height: var(--msx-chat-head-height);
    max-height: var(--msx-chat-head-height);
    border-bottom: 1px solid var(--color-hairline);
    padding: 0 8px;
}

.msx-chat-sidebar-head.is-static {
    grid-template-columns: minmax(0, 1fr);
}

.msx-chat-sidebar-title {
    overflow: hidden;
    color: var(--color-ink);
    font-size: 13px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msx-chat-search {
    display: grid;
    position: relative;
    align-self: center;
    gap: 0;
    height: var(--msx-chat-control-size);
    margin: 0;
    min-width: 0;
}

.msx-chat-search input {
    display: block;
    box-sizing: border-box;
    width: 100%;
    height: var(--msx-chat-control-size);
    min-height: var(--msx-chat-control-size);
    max-height: var(--msx-chat-control-size);
    border: 0;
    border-radius: var(--radius-md);
    appearance: none;
    -webkit-appearance: none;
    background: var(--color-surface-strong);
    color: var(--color-ink);
    margin: 0;
    padding: 0 8px;
    font: inherit;
    font-size: 13px;
    line-height: var(--msx-chat-control-size);
    outline: none;
}

.msx-chat-search input::placeholder {
    color: var(--color-muted);
}

.msx-chat-sidebar-head h1,
.msx-chat-thread-head h1 {
    margin: 0;
    color: var(--color-ink);
    font-size: 20px;
    font-weight: 600;
    line-height: 1.2;
}

.msx-chat-sidebar-head p,
.msx-chat-thread-head p {
    margin: 0;
    color: var(--color-muted);
    font-size: 13px;
    line-height: 1.45;
}

.msx-chat-quick-actions {
    position: relative;
    align-self: center;
    width: var(--msx-chat-control-size);
    height: var(--msx-chat-control-size);
    margin: 0;
    z-index: 12;
}

.msx-chat-quick-actions > summary {
    display: flex;
    box-sizing: border-box;
    width: var(--msx-chat-control-size);
    min-width: var(--msx-chat-control-size);
    height: var(--msx-chat-control-size);
    min-height: var(--msx-chat-control-size);
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--color-muted);
    cursor: pointer;
    font-size: 17px;
    font-weight: 400;
    line-height: 1;
    list-style: none;
    user-select: none;
}

.msx-chat-quick-actions > summary > span {
    display: block;
    line-height: 1;
    transform: translateY(-1px);
}

.msx-chat-sidebar-head .msx-chat-quick-menu {
    top: 0;
    right: auto;
    left: calc(100% + 4px);
}

.msx-chat-quick-actions summary::-webkit-details-marker,
.msx-chat-quick-item summary::-webkit-details-marker {
    display: none;
}

.msx-chat-quick-actions > summary:hover,
.msx-chat-quick-actions[open] > summary {
    background: var(--color-surface);
    color: var(--color-ink);
    box-shadow: var(--shadow-soft);
}

.msx-chat-quick-menu {
    display: grid;
    gap: 1px;
    position: absolute;
    top: 0;
    left: calc(100% + 4px);
    width: min(300px, calc(100vw - 80px));
    border: 1px solid var(--color-hairline);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    padding: 4px;
    box-shadow: var(--shadow-soft);
}

.msx-chat-quick-item > summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    min-height: 34px;
    border-radius: var(--radius-sm);
    padding: 0 10px;
    color: var(--color-ink);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    list-style: none;
}

.msx-chat-quick-item > summary:hover,
.msx-chat-quick-item[open] > summary {
    background: var(--color-surface-strong);
}

.msx-chat-start-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    align-items: end;
    gap: 10px;
    width: 100%;
    border: 0;
    border-radius: var(--radius-md);
    background: transparent;
    padding: 8px 12px 12px;
    box-shadow: none;
}

.msx-chat-group-form {
    grid-template-columns: 1fr;
}

.msx-chat-start-form label {
    display: grid;
    min-width: 0;
    gap: 6px;
}

.msx-chat-start-form span {
    color: var(--color-muted);
    font-size: 12px;
    white-space: nowrap;
}

.msx-chat-start-form input,
.msx-chat-start-form select,
.msx-chat-start-form textarea,
.msx-chat-compose textarea {
    width: 100%;
    border: 1px solid var(--color-hairline-strong);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-ink);
    font: inherit;
}

.msx-chat-start-form input,
.msx-chat-start-form select {
    min-height: 38px;
    padding: 0 14px;
}

.msx-chat-start-form .button-primary {
    min-width: 74px;
    min-height: 38px;
    padding: 8px 16px;
}

.msx-chat-start-form textarea {
    min-height: 74px;
    resize: vertical;
    padding: 9px 12px;
}

.msx-chat-quick-menu .msx-chat-start-form {
    grid-template-columns: minmax(180px, 1fr) auto;
    gap: 8px;
    padding: 6px 8px 8px;
}

.msx-chat-quick-menu .msx-chat-open-form {
    grid-template-areas:
        "hint hint"
        "field action";
    align-items: center;
}

.msx-chat-quick-menu .msx-chat-group-form {
    grid-template-columns: 1fr;
}

.msx-chat-quick-menu .msx-chat-start-form label {
    gap: 4px;
}

.msx-chat-quick-menu .msx-chat-open-form label {
    display: contents;
}

.msx-chat-quick-menu .msx-chat-start-form span {
    font-size: 11px;
}

.msx-chat-quick-menu .msx-chat-open-form label > span {
    grid-area: hint;
}

.msx-chat-quick-menu .msx-chat-start-form input,
.msx-chat-quick-menu .msx-chat-start-form select {
    box-sizing: border-box;
    height: 32px;
    min-height: 32px;
    padding: 0 10px;
}

.msx-chat-quick-menu .msx-chat-open-form input {
    grid-area: field;
}

.msx-chat-quick-menu .msx-chat-start-form .button-primary {
    box-sizing: border-box;
    align-self: end;
    height: 32px;
    min-width: 58px;
    min-height: 32px;
    border-color: transparent;
    background: var(--color-surface-strong);
    color: var(--color-ink);
    padding: 0 12px;
}

.msx-chat-quick-menu .msx-chat-open-form .button-primary {
    grid-area: action;
    width: 32px;
    min-width: 32px;
    align-self: center;
    justify-self: end;
    padding: 0;
}

.msx-chat-mask-icon {
    display: block;
    width: 16px;
    height: 16px;
    background: currentColor;
}

.msx-chat-open-icon {
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14'/%3E%3Cpath d='m12 5 7 7-7 7'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14'/%3E%3Cpath d='m12 5 7 7-7 7'/%3E%3C/svg%3E") center / contain no-repeat;
}

.msx-chat-quick-menu .msx-chat-start-form textarea {
    min-height: 54px;
    padding: 8px 10px;
}

.msx-chat-sidebar-tabs {
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    align-content: start;
    gap: 8px;
    min-height: 0;
    border-right: 1px solid var(--color-hairline);
    background: color-mix(in srgb, var(--color-surface) 70%, var(--color-surface-strong));
    padding: 10px 8px 12px;
}

.msx-chat-tab-stack {
    display: grid;
    align-content: start;
    gap: 8px;
    min-height: 0;
}

.msx-chat-tab-stack > a,
.msx-chat-tab-stack > span {
    display: flex;
    position: relative;
    min-width: 0;
    height: var(--msx-chat-row-height);
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--color-muted);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
}

.msx-chat-tab-stack > a:hover {
    background: var(--color-surface);
    color: var(--color-ink);
}

.msx-chat-tab-stack .is-active {
    background: var(--color-surface);
    color: var(--color-ink);
}

.msx-chat-tab-badge {
    display: inline-flex;
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 16px;
    height: 16px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--color-error);
    color: var(--color-on-error);
    padding: 0 4px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
}

.msx-chat-tab-stack > span {
    opacity: 0.58;
    cursor: default;
}

.msx-chat-list {
    display: grid;
    align-content: start;
    min-height: 0;
    overflow: auto;
    border-top: 0;
}

.msx-chat-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    min-width: 0;
    border-bottom: 1px solid color-mix(in srgb, var(--color-hairline) 72%, transparent);
    border-radius: 0;
    padding: 12px 14px;
    color: inherit;
    text-decoration: none;
}

.msx-chat-row.is-active,
.msx-chat-row:hover {
    background: var(--color-surface-strong);
}

.msx-chat-row[hidden],
.msx-chat-lazy-link[hidden] {
    display: none;
}

.msx-chat-friend-row {
    padding: 0;
}

.msx-chat-friend-row button {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    width: 100%;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    padding: 12px 14px;
    font: inherit;
    text-align: left;
}

.msx-chat-avatar {
    display: inline-flex;
    overflow: hidden;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--color-surface-strong);
    color: var(--color-ink);
    font-size: 15px;
    font-weight: 600;
}

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

.msx-chat-avatar.is-notice {
    background: var(--color-surface);
    color: var(--color-muted);
    font-size: 13px;
}

.msx-chat-row-main {
    display: grid;
    min-width: 0;
    gap: 4px;
}

.msx-chat-row-main strong,
.msx-chat-row-main span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msx-chat-row-main strong {
    color: var(--color-ink);
    font-weight: 600;
}

.msx-chat-row-main span,
.msx-chat-row-side,
.msx-chat-message-meta,
.msx-chat-compose-actions {
    color: var(--color-muted);
    font-size: 13px;
}

.msx-chat-row-side {
    display: grid;
    justify-items: end;
    gap: 4px;
    white-space: nowrap;
}

.msx-chat-unread {
    display: inline-flex;
    min-width: 20px;
    height: 20px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--color-error);
    color: var(--color-on-error);
    font-size: 12px;
    font-weight: 600;
}

.msx-chat-notice-dot {
    display: inline-flex;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--color-error);
}

.msx-chat-thread {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-width: 0;
    min-height: 0;
}

.msx-chat-thread-empty {
    place-items: center;
    padding: 32px;
    background: var(--color-canvas-soft);
    text-align: center;
}

.msx-chat-thread-empty h2 {
    margin: 0 0 8px;
    color: var(--color-ink);
    font-size: 22px;
    font-weight: 600;
}

.msx-chat-thread-empty p {
    margin: 0;
    color: var(--color-muted);
}

.msx-chat-invite-card {
    display: grid;
    justify-items: center;
    gap: 10px;
    width: min(360px, 100%);
}

.msx-chat-invite-kicker,
.msx-chat-invite-status {
    color: var(--color-muted);
    font-size: 13px;
}

.msx-chat-invite-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.msx-chat-invite-actions form {
    margin: 0;
}

.msx-chat-notification-thread {
    background: var(--color-canvas-soft);
}

.msx-chat-notification-pane {
    display: grid;
    align-content: start;
    gap: 16px;
    min-height: 0;
    overflow: auto;
    padding: 16px;
}

.msx-chat-notification-workspace .msx-chat-notification-pane {
    gap: 10px;
    padding: 10px;
}

.msx-chat-notice-section {
    display: grid;
    gap: 10px;
}

.msx-chat-notification-workspace .msx-chat-notice-section {
    gap: 6px;
}

.msx-chat-notice-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--color-muted);
    font-size: 13px;
}

.msx-chat-notice-section-head h2 {
    margin: 0;
    color: var(--color-ink);
    font-size: 15px;
    font-weight: 600;
}

.msx-chat-notice-cards {
    display: grid;
    gap: 8px;
}

.msx-chat-notification-workspace .msx-chat-notice-cards {
    gap: 6px;
}

.msx-chat-notice-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    border-radius: var(--radius-md);
    background: var(--color-surface);
    padding: 12px;
}

.msx-chat-notice-main {
    min-width: 0;
}

.msx-chat-notification-workspace .msx-chat-notice-card {
    gap: 8px;
    padding: 8px 10px;
}

.msx-chat-notice-card.is-read {
    opacity: 0.72;
}

.msx-chat-notice-card h3 {
    margin: 3px 0 0;
    color: var(--color-ink);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
}

.msx-chat-notification-workspace .msx-chat-notice-card h3 {
    margin-top: 1px;
    font-size: 13px;
}

.msx-chat-notice-card p {
    margin: 4px 0 0;
    color: var(--color-muted);
    font-size: 13px;
    line-height: 1.45;
}

.msx-chat-notification-workspace .msx-chat-notice-card p {
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.35;
}

.msx-chat-notice-type,
.msx-chat-notice-muted,
.msx-chat-notice-state {
    color: var(--color-muted);
    font-size: 12px;
    line-height: 1.4;
}

.msx-chat-notice-side {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.msx-chat-notice-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.msx-chat-notification-workspace .msx-chat-notice-actions {
    gap: 6px;
}

.msx-chat-notice-actions form,
.msx-chat-notice-card > form {
    margin: 0;
}

.msx-chat-notice-empty {
    display: grid;
    place-items: center;
    min-height: 180px;
    border-radius: var(--radius-md);
    background: var(--color-surface);
    padding: 24px;
    text-align: center;
}

.msx-chat-notice-empty h3 {
    margin: 0 0 6px;
    color: var(--color-ink);
    font-size: 16px;
    font-weight: 600;
}

.msx-chat-notice-empty p {
    margin: 0;
    color: var(--color-muted);
    font-size: 13px;
}

.msx-chat-thread-head {
    display: grid;
    box-sizing: border-box;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    height: var(--msx-chat-head-height);
    min-height: var(--msx-chat-head-height);
    max-height: var(--msx-chat-head-height);
    border-bottom: 1px solid var(--color-hairline);
    background: var(--color-surface);
    padding: 0 12px;
}

.msx-chat-thread-title {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 6px;
}

.msx-chat-thread-title h1,
.msx-chat-thread-title p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msx-chat-thread-title h1 {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    line-height: 1.3;
}

.msx-chat-thread-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msx-chat-thread-code {
    flex: 0 0 auto;
    color: var(--color-muted);
    font-size: 12px;
    font-weight: 500;
}

.msx-chat-thread-title p {
    flex: 0 0 auto;
    font-size: 12px;
    line-height: 1.3;
}

.msx-chat-thread-actions {
    display: flex;
    position: relative;
    align-items: center;
    gap: 6px;
}

.msx-chat-mobile-back {
    display: none;
}

.msx-chat-member-panel {
    position: relative;
}

.msx-chat-member-panel summary {
    display: flex;
    min-height: var(--msx-chat-control-size);
    align-items: center;
    color: var(--color-muted);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    list-style: none;
}

.msx-chat-member-panel summary::-webkit-details-marker {
    display: none;
}

.msx-chat-member-panel summary:hover,
.msx-chat-member-panel[open] summary {
    color: var(--color-ink);
}

.msx-chat-group-panel {
    display: grid;
    gap: 10px;
    position: absolute;
    z-index: 9;
    top: calc(100% + 10px);
    right: 0;
    width: min(360px, calc(100vw - 32px));
    max-height: min(520px, calc(100dvh - 160px));
    overflow: auto;
    border: 1px solid var(--color-hairline);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    padding: 12px;
    box-shadow: var(--shadow-soft);
}

.msx-chat-member-panel .msx-chat-group-panel .msx-chat-start-form {
    position: static;
    width: auto;
    border: 0;
    padding: 0;
    box-shadow: none;
}

.msx-chat-panel-section {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.msx-chat-panel-section + .msx-chat-panel-section {
    border-top: 1px solid var(--color-hairline);
    margin-top: 2px;
    padding-top: 10px;
}

.msx-chat-panel-section-head {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.msx-chat-panel-section-head span,
.msx-chat-panel-section-head small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msx-chat-panel-section-head span {
    color: var(--color-ink);
    font-size: 13px;
    font-weight: 600;
}

.msx-chat-panel-section-head small {
    color: var(--color-muted);
    font-size: 12px;
    font-weight: 400;
}

.msx-chat-panel-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 8px;
}

.msx-chat-group-settings-form {
    grid-template-columns: 1fr;
}

.msx-chat-group-settings-form.has-title {
    grid-template-columns: minmax(0, 1fr) max-content;
}

.msx-chat-group-settings-form button {
    grid-column: 1 / -1;
    justify-self: end;
}

.msx-chat-group-panel button {
    min-height: 32px;
    padding: 0 12px;
    white-space: nowrap;
}

.msx-chat-group-footer-actions {
    --msx-chat-footer-action-height: 24px;
    --msx-chat-footer-action-font-size: 13px;

    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    height: var(--msx-chat-footer-action-height);
}

.msx-chat-join-switch-form,
.msx-chat-group-leave-form {
    display: grid;
    height: var(--msx-chat-footer-action-height);
    min-width: 0;
    align-items: center;
    margin: 0;
}

.msx-chat-footer-action {
    display: inline-flex;
    height: var(--msx-chat-footer-action-height);
    min-height: var(--msx-chat-footer-action-height);
    min-width: 0;
    align-items: center;
    justify-content: center;
    color: var(--color-muted);
    font-size: var(--msx-chat-footer-action-font-size);
    font-weight: 500;
    line-height: 1;
}

.msx-chat-panel-text-action {
    min-height: 0;
    border: 0;
    background: transparent;
    color: var(--color-muted);
    cursor: pointer;
    padding: 0;
    font: inherit;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
}

.msx-chat-panel-text-action:hover {
    color: var(--color-ink);
}

.msx-chat-checkbox-line {
    gap: 7px;
    justify-content: flex-start;
    cursor: pointer;
}

.msx-chat-checkbox-line input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.msx-chat-checkbox-box {
    display: inline-flex;
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-hairline-strong);
    border-radius: 3px;
    background: var(--color-surface);
}

.msx-chat-checkbox-line input:checked + .msx-chat-checkbox-box {
    border-color: var(--color-muted);
    background: var(--color-muted);
}

.msx-chat-checkbox-line input:checked + .msx-chat-checkbox-box::before {
    width: 7px;
    height: 4px;
    border-bottom: 2px solid var(--color-surface);
    border-left: 2px solid var(--color-surface);
    content: "";
    transform: rotate(-45deg) translate(1px, -1px);
}

.msx-chat-checkbox-line input:focus-visible + .msx-chat-checkbox-box {
    outline: 2px solid color-mix(in srgb, var(--color-ink) 28%, transparent);
    outline-offset: 2px;
}

.msx-chat-footer-action-text {
    overflow: hidden;
    color: var(--color-muted);
    font-size: var(--msx-chat-footer-action-font-size);
    font-weight: 500;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msx-chat-member-panel .msx-chat-group-panel .msx-chat-start-form textarea {
    min-height: 56px;
}

.msx-chat-panel-form label {
    display: grid;
    min-width: 0;
    gap: 6px;
}

.msx-chat-panel-form span {
    color: var(--color-muted);
    font-size: 12px;
}

.msx-chat-panel-form input,
.msx-chat-panel-form select {
    width: 100%;
    min-width: 0;
    min-height: 38px;
    border: 1px solid var(--color-hairline-strong);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-ink);
    padding: 0 12px;
    font: inherit;
}

.msx-chat-avatar-upload {
    justify-items: start;
    min-width: max-content;
}

.msx-chat-avatar-upload input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 1px;
    border: 0;
    margin: 0;
    overflow: hidden;
    padding: 0;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.msx-chat-panel-form .msx-chat-avatar-upload-button {
    display: inline-flex;
    width: auto;
    min-height: 32px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-hairline-strong);
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--color-ink);
    cursor: pointer;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
}

.msx-chat-avatar-upload:hover .msx-chat-avatar-upload-button,
.msx-chat-avatar-upload:focus-within .msx-chat-avatar-upload-button {
    background: var(--color-surface-strong);
}

.msx-chat-leader-list {
    display: grid;
    gap: 2px;
}

.msx-chat-member-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    min-width: 0;
    border-radius: var(--radius-md);
    padding: 7px 6px;
}

.msx-chat-member-row:hover {
    background: color-mix(in srgb, var(--color-surface-strong) 46%, transparent);
}

.msx-chat-leader-list .msx-chat-member-row {
    gap: 8px;
    min-height: 30px;
    padding: 3px 4px;
}

.msx-chat-leader-list .msx-chat-avatar {
    width: 26px;
    height: 26px;
    font-size: 12px;
}

.msx-chat-member-main {
    display: grid;
    min-width: 0;
    gap: 2px;
}

.msx-chat-member-main strong,
.msx-chat-member-main span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msx-chat-member-main strong {
    color: var(--color-ink);
    font-size: 14px;
    font-weight: 600;
}

.msx-chat-leader-list .msx-chat-member-main strong {
    font-size: 13px;
    font-weight: 500;
}

.msx-chat-member-main span {
    color: var(--color-muted);
    font-size: 12px;
}

.msx-chat-muted-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
}

.msx-chat-muted-remove-form {
    margin: 0;
}

.msx-chat-group-panel .msx-chat-muted-remove {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    border: 0;
    background: transparent;
    color: var(--color-muted);
    cursor: pointer;
    padding: 0;
    font: inherit;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
}

.msx-chat-group-panel .msx-chat-muted-remove:hover {
    color: var(--color-ink);
}

.msx-chat-panel-empty {
    margin: 0;
    color: var(--color-muted);
    font-size: 12px;
    line-height: 1.5;
}

.msx-chat-group-leave-form .button-link {
    border: 0;
    background: transparent;
    color: var(--color-muted);
    cursor: pointer;
    padding: 0;
    font: inherit;
    font-size: var(--msx-chat-footer-action-font-size);
    font-weight: 500;
    line-height: 1;
    place-self: center end;
}

.msx-chat-group-panel button.msx-chat-footer-action {
    min-height: var(--msx-chat-footer-action-height);
    padding: 0;
}

.msx-chat-message-pane {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    min-height: 0;
    background: var(--color-canvas-soft);
}

.msx-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
    overflow: auto;
    background: var(--color-canvas-soft);
    padding: 18px 18px 20px;
}

.msx-chat-messages::before {
    content: "";
    margin-top: auto;
}

.msx-chat-message {
    display: grid;
    width: fit-content;
    max-width: min(560px, calc(50% + 40px));
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 5px;
    column-gap: 8px;
    align-self: flex-start;
}

.msx-chat-message.is-mine {
    grid-template-columns: minmax(0, 1fr) auto;
    align-self: flex-end;
}

.msx-chat-message-avatar {
    display: inline-flex;
    overflow: hidden;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--color-surface-strong);
    color: var(--color-ink);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
}

.msx-chat-message-avatar[data-msx-chat-sender-menu] {
    cursor: context-menu;
}

.msx-chat-message-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.msx-chat-message.is-mine .msx-chat-message-avatar {
    grid-column: 2;
}

.msx-chat-message-stack {
    display: grid;
    min-width: 0;
    gap: 5px;
}

.msx-chat-message.is-mine .msx-chat-message-stack {
    grid-column: 1;
    grid-row: 1;
}

.msx-chat-message-meta {
    display: flex;
    position: relative;
    width: max-content;
    max-width: 100%;
    gap: 8px;
    padding: 0 4px;
}

.msx-chat-message-meta time {
    position: absolute;
    top: 0;
    left: calc(100% + 8px);
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
}

.msx-chat-message:hover .msx-chat-message-meta time,
.msx-chat-message:focus-within .msx-chat-message-meta time {
    opacity: 1;
}

.msx-chat-message-sender {
    cursor: context-menu;
}

.msx-chat-message.is-mine .msx-chat-message-meta {
    justify-self: end;
    justify-content: flex-end;
}

.msx-chat-message.is-mine .msx-chat-message-meta time {
    right: calc(100% + 8px);
    left: auto;
}

.msx-chat-message-body {
    --msx-chat-gallery-cell: clamp(64px, 8vw, 92px);
    box-sizing: border-box;
    width: fit-content;
    max-width: 100%;
    justify-self: start;
    border-radius: var(--radius-md);
    border-top-left-radius: 4px;
    background: var(--color-surface);
    padding: 10px 13px;
    overflow-wrap: anywhere;
}

.msx-chat-message-body.msx-content a {
    color: #2563eb;
    text-decoration-color: currentColor;
}

html[data-color-scheme="ink"] .msx-chat-message-body.msx-content a {
    color: #60a5fa;
}

html .msx-chat-message-body.msx-content a[href*="#msx-chat-message-"] {
    color: inherit;
    text-decoration: none;
}

.msx-chat-message-body.has-image-gallery {
    padding: 8px;
}

.msx-chat-message-body.is-image-only,
.msx-chat-message-body:not([data-msx-chat-gallery-ready="1"]):has(.content-image) {
    background: transparent;
    padding: 0;
}

.msx-chat-message.is-mine .msx-chat-message-body {
    justify-self: end;
    border-top-left-radius: var(--radius-md);
    border-top-right-radius: 4px;
}

.msx-chat-message.is-pending .msx-chat-message-body,
.msx-chat-message.is-pending .msx-chat-message-meta,
.msx-chat-message.is-pending .msx-chat-message-avatar {
    opacity: 0.78;
}

.msx-chat-message.is-new .msx-chat-message-body {
    animation: msx-chat-message-enter 180ms cubic-bezier(0.22, 1, 0.36, 1) both;
    transform-origin: left top;
    will-change: opacity, transform;
}

.msx-chat-message.is-mine.is-new .msx-chat-message-body {
    animation-name: msx-chat-message-enter-mine;
    transform-origin: right top;
}

.msx-chat-message.is-located .msx-chat-message-body {
    outline: 2px solid var(--color-error);
    outline-offset: 2px;
    animation: msx-chat-locate-flash 1.2s ease-out both;
}

@keyframes msx-chat-message-enter {
    from {
        opacity: 0.35;
        transform: translate3d(-8px, 4px, 0) scale(0.985);
    }

    to {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
}

@keyframes msx-chat-message-enter-mine {
    from {
        opacity: 0.35;
        transform: translate3d(8px, 4px, 0) scale(0.985);
    }

    to {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
}

@keyframes msx-chat-locate-flash {
    0% {
        outline-color: transparent;
        outline-offset: 6px;
    }

    18%,
    72% {
        outline-color: var(--color-error);
        outline-offset: 2px;
    }

    100% {
        outline-color: color-mix(in srgb, var(--color-error) 40%, transparent);
        outline-offset: 2px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .msx-chat-message.is-new .msx-chat-message-body {
        animation: none;
        will-change: auto;
    }

    .msx-chat-message.is-located .msx-chat-message-body {
        animation: none;
    }
}

.msx-chat-image-gallery {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: var(--msx-chat-gallery-cell);
    gap: 4px;
    width: calc((var(--msx-chat-gallery-cell) * 3) + 8px);
    max-width: 100%;
    margin-top: 8px;
    overflow: hidden;
}

.msx-chat-image-gallery:first-child {
    margin-top: 0;
}

.msx-chat-image-gallery[data-msx-chat-gallery-count="1"] {
    grid-template-columns: 1fr;
    grid-auto-rows: calc(var(--msx-chat-gallery-cell) * 1.55);
    width: calc(var(--msx-chat-gallery-cell) * 1.55);
}

.msx-chat-image-gallery[data-msx-chat-gallery-count="2"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: calc((var(--msx-chat-gallery-cell) * 2) + 4px);
}

.msx-chat-message-body:not([data-msx-chat-gallery-ready="1"]) :is(p, figure) {
    margin-block: 0;
}

.msx-chat-message-body:not([data-msx-chat-gallery-ready="1"]) .content-image {
    display: inline-block;
    box-sizing: border-box;
    width: var(--msx-chat-gallery-cell) !important;
    max-width: var(--msx-chat-gallery-cell);
    height: var(--msx-chat-gallery-cell) !important;
    aspect-ratio: 1 / 1;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--color-surface-strong);
    margin: 0 4px 4px 0;
    padding-right: 0;
    object-fit: cover;
    object-position: center;
    vertical-align: top;
}

.msx-chat-image-gallery .content-image {
    display: block;
    width: 100% !important;
    max-width: none;
    height: 100% !important;
    aspect-ratio: 1 / 1;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    margin: 0;
    object-fit: cover;
    object-position: center;
}

.msx-chat-image-gallery .content-image,
.msx-chat-message-body:not([data-msx-chat-gallery-ready="1"]) .content-image {
    cursor: zoom-in;
}

html.msx-chat-image-viewer-open {
    overflow: hidden;
}

.msx-chat-image-viewer {
    display: grid;
    position: fixed;
    inset: 0;
    z-index: 120;
    grid-template-rows: minmax(0, 1fr);
    background: rgb(12 10 9 / 84%);
    padding: 22px;
}

.msx-chat-image-viewer-stage {
    display: flex;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: none;
}

.msx-chat-image-viewer-stage:active {
    cursor: grabbing;
}

.msx-chat-image-viewer img {
    display: block;
    max-width: min(94vw, 1280px);
    max-height: calc(100dvh - 96px);
    border-radius: var(--radius-md);
    object-fit: contain;
    transform-origin: center;
    user-select: none;
    will-change: transform;
}

.msx-chat-image-viewer-close,
.msx-chat-image-viewer-tools {
    position: fixed;
    z-index: 121;
    border: 1px solid color-mix(in srgb, var(--color-hairline) 50%, transparent);
    background: color-mix(in srgb, var(--color-surface) 92%, transparent);
    box-shadow: var(--shadow-soft);
}

.msx-chat-image-viewer-close {
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-pill);
    color: var(--color-ink);
    cursor: pointer;
    font: inherit;
    font-size: 20px;
    line-height: 1;
}

.msx-chat-image-viewer-tools {
    display: flex;
    left: 50%;
    bottom: 14px;
    gap: 2px;
    transform: translateX(-50%);
    border-radius: var(--radius-pill);
    padding: 4px;
}

.msx-chat-image-viewer-tools button {
    min-width: 34px;
    height: 28px;
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--color-ink);
    cursor: pointer;
    padding: 0 10px;
    font: inherit;
    font-size: 13px;
    line-height: 1;
}

.msx-chat-image-viewer-close:hover,
.msx-chat-image-viewer-tools button:hover {
    background: var(--color-surface-strong);
}

.msx-chat-optimistic-quote {
    margin-bottom: 7px;
    border-radius: var(--radius-sm);
    background: var(--color-canvas-soft);
    color: var(--color-muted);
    padding: 6px 8px;
    font-size: 12px;
    line-height: 1.45;
}

.msx-chat-client-tip {
    align-self: center;
    max-width: min(520px, 90%);
    margin: 2px 0;
    border-radius: var(--radius-pill);
    background: color-mix(in srgb, var(--color-ink) 8%, transparent);
    color: var(--color-muted);
    padding: 6px 12px;
    font-size: 13px;
    line-height: 1.45;
    text-align: center;
}

.msx-chat-lazy-link {
    display: block;
    padding: 10px 12px;
    color: var(--color-muted);
    font-size: 13px;
    text-align: center;
    text-decoration: none;
}

.msx-chat-lazy-link:hover {
    color: var(--color-ink);
}

.msx-chat-lazy-link.is-loading {
    pointer-events: none;
    opacity: 0.62;
}

.msx-chat-context-menu {
    display: grid;
    position: fixed;
    z-index: 80;
    min-width: 116px;
    border: 1px solid var(--color-hairline);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    padding: 5px;
    box-shadow: var(--shadow-soft);
}

.msx-chat-context-menu button {
    width: 100%;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-ink);
    cursor: pointer;
    padding: 8px 10px;
    font: inherit;
    font-size: 13px;
    text-align: left;
}

.msx-chat-context-menu button:hover {
    background: var(--color-surface-strong);
}

.msx-chat-context-menu button.is-danger {
    color: var(--color-ink);
}

.msx-chat-compose {
    display: grid;
    position: relative;
    border-top: 1px solid var(--color-hairline);
    background: var(--color-surface);
    padding: 8px 16px 0;
}

.msx-chat-compose.is-drop-target::after {
    content: "";
    position: absolute;
    inset: 6px 12px;
    pointer-events: none;
    border: 1px dashed color-mix(in srgb, var(--color-ink) 38%, transparent);
    border-radius: var(--radius-md);
}

.msx-chat-compose-resizer {
    position: absolute;
    top: -4px;
    right: 0;
    left: 0;
    height: 8px;
    cursor: ns-resize;
    touch-action: none;
    z-index: 2;
}

.msx-chat-compose-resizer::before {
    content: "";
    position: absolute;
    top: 3px;
    right: 0;
    left: 0;
    height: 1px;
    background: transparent;
}

.msx-chat-compose-resizer:hover::before,
.msx-chat-compose.is-resizing .msx-chat-compose-resizer::before {
    background: var(--color-hairline-strong);
}

.msx-chat-compose-box {
    display: flex;
    position: relative;
    box-sizing: border-box;
    min-height: 70px;
    flex-direction: column;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 0 0 33px;
}

.msx-chat-quote-preview {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    margin: 0 0 6px;
    border-radius: var(--radius-md);
    background: var(--color-canvas-soft);
    padding: 7px 9px;
    color: var(--color-muted);
    font-size: 12px;
    line-height: 1.4;
}

.msx-chat-quote-preview[hidden] {
    display: none;
}

.msx-chat-quote-preview span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msx-chat-quote-preview strong {
    color: var(--color-ink);
    font-weight: 500;
}

.msx-chat-quote-preview button {
    border: 0;
    background: transparent;
    color: var(--color-muted);
    cursor: pointer;
    padding: 2px 4px;
    font: inherit;
}

.msx-chat-compose textarea {
    flex: 1 1 auto;
    min-height: 40px;
    resize: none;
    border: 0;
    background: transparent;
    outline: none;
    padding: 6px 2px 0;
}

.msx-chat-compose-actions {
    display: flex;
    position: absolute;
    right: 0;
    bottom: 5px;
    left: 0;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    max-width: none;
    min-height: 28px;
}

.msx-chat-image-button {
    display: inline-flex;
    position: relative;
    box-sizing: border-box;
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--color-muted);
    cursor: pointer;
    margin: 0;
    padding: 0;
    font-size: 12px;
    line-height: 1;
    appearance: none;
    -webkit-appearance: none;
}

.msx-chat-image-icon {
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='18' height='18' x='3' y='3' rx='2' ry='2'/%3E%3Ccircle cx='9' cy='9' r='2'/%3E%3Cpath d='m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='18' height='18' x='3' y='3' rx='2' ry='2'/%3E%3Ccircle cx='9' cy='9' r='2'/%3E%3Cpath d='m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21'/%3E%3C/svg%3E") center / contain no-repeat;
}

.msx-chat-image-button:hover {
    background: transparent;
    color: var(--color-ink);
}

.msx-chat-image-button input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    clip-path: inset(50%);
}

.msx-chat-image-preview {
    display: flex;
    overflow-x: auto;
    gap: 6px;
    min-height: 46px;
    background: var(--color-canvas-soft);
    padding: 0 18px 12px;
}

.msx-chat-image-preview[hidden] {
    display: none;
}

.msx-chat-image-preview-item {
    display: block;
    overflow: hidden;
    position: relative;
    width: 46px;
    height: 46px;
    flex: 0 0 auto;
    border-radius: var(--radius-md);
    background: var(--color-surface-strong);
}

.msx-chat-image-preview-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.msx-chat-image-preview-item button {
    position: absolute;
    right: 2px;
    bottom: 2px;
    border: 0;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--color-surface) 86%, transparent);
    color: var(--color-ink);
    cursor: pointer;
    padding: 2px 4px;
    font: inherit;
    font-size: 11px;
    line-height: 1;
}

.msx-chat-compose .button-primary {
    display: inline-flex;
    box-sizing: border-box;
    width: 46px;
    height: 28px;
    min-width: 46px;
    min-height: 28px;
    align-items: center;
    justify-content: center;
    flex: 0 0 46px;
    border: 0;
    border-radius: var(--radius-md);
    background: var(--color-surface-strong);
    color: var(--color-ink);
    margin: 0;
    padding: 0;
    font-size: 12px;
    line-height: 1;
    appearance: none;
    -webkit-appearance: none;
}

@media (max-width: 760px) {
    body:has(.msx-chat-shell) {
        overflow: hidden;
    }

    body:has(.msx-chat-shell) > .site-header,
    body:has(.msx-chat-shell) > .site-footer {
        display: none;
    }

    .page-shell:has(> .msx-chat-shell) {
        width: 100%;
        min-height: 100dvh;
        padding: 0;
    }

    .msx-chat-shell {
        --msx-chat-head-height: 42px;
        --msx-chat-control-size: 32px;
        --msx-chat-row-height: 40px;
    }

    .msx-chat-workspace {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr);
        height: 100dvh;
        min-height: 0;
        max-height: none;
        border: 0;
        border-radius: 0;
    }

    .msx-chat-workspace:has([data-msx-chat-thread]) .msx-chat-sidebar,
    .msx-chat-workspace:not(:has([data-msx-chat-thread])) .msx-chat-thread-placeholder {
        display: none;
    }

    .msx-chat-notification-workspace {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr);
        width: 100%;
        min-height: 0;
        height: 100dvh;
    }

    .msx-chat-sidebar {
        grid-template-columns: 1fr;
        overflow: hidden;
        border-right: 0;
        border-bottom: 0;
    }

    .msx-chat-notification-workspace .msx-chat-sidebar,
    .msx-chat-workspace:has(.msx-chat-invite-card) .msx-chat-sidebar {
        grid-row: 1;
        grid-column: 1;
        pointer-events: none;
    }

    .msx-chat-notification-workspace .msx-chat-sidebar-panel,
    .msx-chat-workspace:has(.msx-chat-invite-card) .msx-chat-sidebar-panel {
        display: none;
    }

    .msx-chat-notification-thread,
    .msx-chat-workspace:has(.msx-chat-invite-card) .msx-chat-thread-empty {
        grid-row: 1;
        grid-column: 1;
    }

    .msx-chat-sidebar-tabs {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 30;
        grid-template-rows: auto;
        gap: 6px;
        border-top: 1px solid var(--color-hairline);
        border-right: 0;
        background: var(--color-surface);
        padding: 5px 8px max(5px, env(safe-area-inset-bottom));
        pointer-events: auto;
    }

    .msx-chat-tab-stack {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        align-content: stretch;
        gap: 4px;
    }

    .msx-chat-tab-stack > a,
    .msx-chat-tab-stack > span {
        height: 44px;
        font-size: 12px;
    }

    .msx-chat-tab-badge {
        top: 4px;
        right: calc(50% - 22px);
    }

    .msx-chat-sidebar-panel,
    .msx-chat-notification-pane {
        padding-bottom: calc(62px + env(safe-area-inset-bottom));
    }

    .msx-chat-workspace:has(.msx-chat-invite-card) .msx-chat-thread-empty {
        padding-bottom: calc(94px + env(safe-area-inset-bottom));
    }

    .msx-chat-sidebar-head {
        gap: 6px;
        padding: 0 8px;
    }

    .msx-chat-row {
        gap: 10px;
        min-height: 58px;
        padding: 10px;
    }

    .msx-chat-friend-row {
        min-height: 58px;
        padding: 0;
    }

    .msx-chat-friend-row button {
        min-height: 58px;
        padding: 10px;
    }

    .msx-chat-avatar {
        width: 34px;
        height: 34px;
        font-size: 13px;
    }

    .msx-chat-sidebar-head .msx-chat-quick-menu {
        top: calc(100% + 4px);
        right: 0;
        left: auto;
        width: min(304px, calc(100vw - 16px));
        max-height: calc(100dvh - 68px);
        overflow: auto;
    }

    .msx-chat-start-form {
        grid-template-columns: 1fr;
    }

    .msx-chat-thread {
        min-width: 0;
    }

    .msx-chat-thread-head {
        grid-template-columns: auto minmax(0, 1fr) auto;
        gap: 6px;
        padding: 0 8px;
    }

    .msx-chat-mobile-back {
        display: inline-flex;
        height: 32px;
        align-items: center;
        justify-content: center;
        border-radius: var(--radius-md);
        color: var(--color-muted);
        padding: 0 8px;
        font-size: 13px;
        font-weight: 500;
        line-height: 1;
        text-decoration: none;
    }

    .msx-chat-mobile-back:hover {
        background: var(--color-surface-strong);
        color: var(--color-ink);
    }

    .msx-chat-thread-title h1 {
        font-size: 15px;
        line-height: 1.2;
    }

    .msx-chat-thread-actions {
        gap: 4px;
    }

    .msx-chat-member-panel summary {
        min-height: 32px;
        font-size: 12px;
    }

    .msx-chat-group-panel {
        position: fixed;
        top: 52px;
        right: 8px;
        left: 8px;
        width: auto;
        max-height: calc(100dvh - 72px);
    }

    .msx-chat-messages {
        gap: 10px;
        padding: 12px 10px 14px;
    }

    .msx-chat-message {
        max-width: min(84%, 420px);
    }

    .msx-chat-message-avatar {
        width: 30px;
        height: 30px;
        flex-basis: 30px;
        font-size: 12px;
    }

    .msx-chat-message-meta,
    .msx-chat-compose-actions {
        font-size: 12px;
    }

    .msx-chat-message-body {
        --msx-chat-gallery-cell: clamp(68px, 25vw, 92px);
        padding: 8px 10px;
        font-size: 14px;
        line-height: 1.55;
    }

    .msx-chat-message-body.has-image-gallery,
    .msx-chat-message-body.is-image-only {
        padding: 0;
    }

    .msx-chat-compose {
        padding: 6px 10px 0;
    }

    .msx-chat-compose-box {
        min-height: 62px;
        padding-bottom: 33px;
    }

    .msx-chat-compose textarea {
        min-height: 34px;
        padding-top: 4px;
        font-size: 14px;
    }

    .msx-chat-image-preview {
        min-height: 42px;
        padding: 0 10px 8px;
    }

    .msx-chat-image-preview-item {
        width: 42px;
        height: 42px;
    }

    .msx-chat-notice-card {
        grid-template-columns: 1fr;
        align-items: start;
    }
}

@media (max-width: 420px) {
    .msx-chat-sidebar {
        grid-template-columns: 1fr;
    }

    .msx-chat-row-main span,
    .msx-chat-row-side {
        font-size: 12px;
    }

    .msx-chat-message {
        max-width: 86%;
    }

    .msx-chat-message-body {
        --msx-chat-gallery-cell: clamp(64px, 27vw, 88px);
    }
}
