.theme-reply-panel {
    display: grid;
    gap: 22px;
    border: 0;
    border-radius: var(--radius-md);
    background: var(--color-surface);
    margin-top: 0;
    padding: 22px 24px 24px;
    box-shadow: var(--shadow-soft);
}

html[data-color-scheme="ink"] .theme-reply-panel {
    background: var(--color-surface);
}

.theme-reply-toolbar {
    display: flex;
    width: 100%;
    max-width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.theme-reply-count-pill {
    display: inline-flex;
    min-height: 32px;
    align-items: center;
    border: 1px solid var(--control-border-hover);
    border-radius: var(--radius-pill);
    background: var(--control-bg-active);
    color: var(--control-text-active);
    padding: 0 12px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
}

.theme-reply-sort {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 6px;
}

.theme-reply-sort-link {
    display: inline-flex;
    min-height: 32px;
    align-items: center;
    border-radius: var(--radius-button);
    background: var(--color-canvas-soft);
    color: var(--color-muted);
    padding: 0 12px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
}

.theme-reply-sort-link:hover,
.theme-reply-sort-link:focus-visible,
.theme-reply-sort-link.is-active {
    background: var(--control-bg-active);
    color: var(--control-text-active);
}

.theme-reply-list {
    display: grid;
    gap: 2px;
    border-top: 0;
}

.theme-reply-item {
    position: relative;
    display: grid;
    min-width: 0;
    gap: 10px;
    padding: 18px 0;
    scroll-margin-top: 96px;
}

.theme-reply-thread-root,
.theme-reply-detail-comment {
    scroll-margin-top: 96px;
}

.theme-reply-item.is-reply-located,
.theme-reply-thread-root.is-reply-located,
.theme-reply-detail-comment.is-reply-located {
    animation: theme-reply-locate-pulse 2200ms ease;
}

@keyframes theme-reply-locate-pulse {
    0%,
    100% {
        box-shadow: none;
    }

    18%,
    62% {
        box-shadow: inset 3px 0 0 var(--color-error);
    }
}

.theme-reply-item:first-child {
    padding-top: 0;
}

.theme-reply-item:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.theme-reply-corner-actions {
    position: absolute;
    top: 18px;
    right: 0;
    z-index: 4;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--color-muted);
    font-size: 13px;
}

.theme-reply-item:first-child .theme-reply-corner-actions {
    top: 0;
}

.theme-reply-corner-actions .theme-reply-delete-form {
    display: inline-flex;
    margin: 0;
}

.theme-reply-corner-actions .button-link {
    color: var(--color-muted);
    font-size: 13px;
    font-weight: 400;
}

.theme-reply-corner-actions .button-link:hover,
.theme-reply-corner-actions .report-popover-trigger:hover {
    color: var(--color-ink);
}

.theme-reply-floor-head {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 10px;
    padding-right: 82px;
}

.theme-reply-avatar-link {
    display: inline-flex;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
}

.theme-reply-avatar-link img,
.theme-reply-avatar-link span {
    display: inline-flex;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--color-surface-strong);
    color: var(--color-ink);
    font-weight: 600;
    object-fit: cover;
}

.theme-reply-meta {
    min-width: 0;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 0;
}

.theme-reply-meta strong {
    min-width: 0;
    color: var(--color-ink);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
}

.theme-reply-meta strong a {
    display: inline-block;
    max-width: min(260px, 45vw);
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
    white-space: nowrap;
}

.theme-reply-meta a:hover {
    color: var(--color-primary);
}

.theme-reply-body {
    --reply-content-image-default-width: clamp(72px, 11vw, 88px);
    --reply-content-image-inline-gap: 4px;

    color: var(--color-body);
    line-height: 1.75;
}

.theme-reply-body :is(p, h2, h3):first-child {
    margin-top: 0;
}

.theme-reply-body :is(p, h2, h3):last-child {
    margin-bottom: 0;
}

.theme-reply-body img {
    max-width: 100%;
    height: auto;
}

.theme-reply-preview {
    --reply-content-image-default-width: clamp(56px, 14vw, 72px);

    display: grid;
    gap: 8px;
    min-width: 0;
    max-width: 100%;
}

.theme-reply-preview-images {
    position: relative;
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    align-items: center;
    width: fit-content;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.theme-reply-preview-images.is-synced {
    overflow: visible;
}

.theme-reply-body .content-image,
.theme-reply-thread-body .content-image,
.theme-reply-detail-comment-body .content-image {
    display: inline-block;
    box-sizing: border-box;
    width: var(--reply-content-image-default-width) !important;
    max-width: var(--reply-content-image-default-width);
    aspect-ratio: 1 / 1;
    height: auto !important;
    max-height: none;
    margin: 4px 0;
    padding-right: var(--reply-content-image-inline-gap);
    border: 0;
    border-radius: var(--radius-md);
    object-fit: cover;
    object-position: center;
    vertical-align: top;
}

.theme-reply-preview-images .content-image {
    flex: 0 0 auto;
    margin: 0;
    padding-right: 0;
}

.theme-reply-preview-more {
    display: inline-flex;
    position: absolute;
    right: 5px;
    bottom: 4px;
    align-items: center;
    justify-content: center;
    color: var(--color-on-dark);
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    pointer-events: none;
    text-shadow: 0 1px 3px color-mix(in srgb, var(--color-ink) 70%, transparent);
}

.theme-reply-preview-more[hidden],
.theme-reply-preview-images .content-image[hidden] {
    display: none;
}

.theme-reply-preview-text {
    display: -webkit-box;
    max-width: 100%;
    margin: 0;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow-wrap: anywhere;
}

.theme-reply-mention {
    color: #0eaf5c;
    font-weight: 500;
}

html[data-color-scheme="ink"] .theme-reply-mention {
    color: #0eaf5c;
}

.theme-reply-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 2px;
    padding-right: 0;
    width: 100%;
}

.theme-reply-actions.has-chip-pager {
    padding-right: 96px;
}

.theme-reply-actions form {
    display: inline-flex;
    margin: 0;
}

.theme-reply-thread-count {
    color: var(--color-muted);
    font-size: 13px;
    line-height: 1;
    white-space: nowrap;
}

.theme-reply-chip-section {
    min-width: 0;
    margin-top: 2px;
}

.theme-reply-chip-list {
    --reply-chip-row-height: 40px;
    --reply-chip-row-gap: 8px;
    --reply-chip-max-width: calc((100% - (var(--reply-chip-row-gap) * 2)) / 3);

    display: flex;
    flex-wrap: wrap;
    gap: var(--reply-chip-row-gap);
    max-height: calc((var(--reply-chip-row-height) * 3) + (var(--reply-chip-row-gap) * 2));
    overflow: hidden;
}

.theme-reply-chip-list.is-paginated {
    max-height: none;
    overflow: visible;
}

.theme-reply-chip {
    position: relative;
    display: inline-flex;
    max-width: min(360px, var(--reply-chip-max-width));
    min-width: 0;
    min-height: 38px;
    align-items: center;
    gap: 7px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--color-canvas-soft);
    color: var(--color-body);
    cursor: pointer;
    padding: 6px 10px 6px 6px;
    transition:
        background-color 160ms ease,
        color 160ms ease;
}

.theme-reply-chip[hidden] {
    display: none;
}

.theme-reply-chip:hover,
.theme-reply-chip:focus-visible {
    background: var(--color-surface-strong);
    color: var(--color-ink);
}

.theme-reply-chip:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.theme-reply-chip::after {
    content: attr(data-reply-author);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 8px;
    z-index: 2;
    display: none;
    max-width: 180px;
    overflow: hidden;
    border-radius: var(--radius-pill);
    background: var(--reply-chip-tooltip-bg);
    color: var(--reply-chip-tooltip-text);
    font-size: 12px;
    line-height: 1;
    padding: 7px 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-shadow: var(--shadow-soft);
}

.theme-reply-chip:hover::after,
.theme-reply-chip:focus-visible::after {
    display: block;
}

.theme-reply-chip-avatar,
.theme-reply-chip-avatar-media {
    display: inline-flex;
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.theme-reply-chip-avatar-media {
    background: var(--color-surface-strong);
    color: var(--color-ink);
    font-size: 12px;
    font-weight: 600;
    object-fit: cover;
}

.theme-reply-chip-thumb {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    overflow: hidden;
    border-radius: var(--radius-sm);
    background: var(--color-surface-strong);
}

.theme-reply-chip-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.theme-reply-chip-thumb span {
    position: absolute;
    right: 3px;
    bottom: 2px;
    color: #ffffff;
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

.theme-reply-chip-text {
    overflow: hidden;
    min-width: 0;
    max-width: 280px;
    font-size: 14px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.theme-reply-chip-count {
    display: inline-flex;
    flex: 0 0 auto;
    min-width: 18px;
    height: 18px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-pill);
    background: var(--color-surface);
    color: var(--color-muted);
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    padding: 0 6px;
}

.theme-reply-chip-pager {
    position: absolute;
    right: 0;
    bottom: 18px;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin: 0;
    width: auto;
}

.theme-reply-item:last-child .theme-reply-chip-pager {
    bottom: 0;
}

.theme-reply-chip-pager[hidden] {
    display: none;
}

.theme-reply-chip-pager .msx-pagination-list,
.theme-reply-detail-comment-pager .msx-pagination-list {
    gap: 4px;
    width: auto;
}

.theme-reply-drawer-root[hidden] {
    display: none;
}

.theme-reply-drawer {
    position: fixed;
    top: 3px;
    right: 3px;
    bottom: 3px;
    z-index: 70;
    display: grid;
    width: min(460px, calc(100vw - 32px));
    overflow: hidden;
    border-radius: var(--radius-md);
    background: var(--color-surface);
    box-shadow: 0 18px 54px rgba(0, 0, 0, 0.18);
}

html[data-color-scheme="ink"] .theme-reply-drawer {
    box-shadow: 0 18px 54px rgba(0, 0, 0, 0.38);
}

.theme-reply-drawer-content {
    min-width: 0;
    overflow: auto;
    padding: 3px;
}

.theme-reply-thread-root {
    display: grid;
    min-width: 0;
    gap: 14px;
    border-radius: var(--radius-md);
    background: transparent;
    padding: 18px 20px;
}

.theme-reply-thread-head {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 9px;
}

.theme-reply-thread-avatar,
.theme-reply-thread-avatar-media {
    display: inline-flex;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.theme-reply-thread-avatar-media {
    background: var(--color-surface-strong);
    color: var(--color-ink);
    font-size: 12px;
    font-weight: 600;
    object-fit: cover;
}

.theme-reply-thread-title {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    align-items: baseline;
    gap: 8px;
}

.theme-reply-thread-delete-form,
.theme-reply-detail-delete-form {
    display: inline-flex;
    flex: 0 0 auto;
    margin: 0 0 0 auto;
}

.theme-reply-thread-delete-form .button-link,
.theme-reply-detail-delete-form .button-link {
    color: var(--color-muted);
    font-size: 13px;
    font-weight: 400;
}

.theme-reply-thread-delete-form .button-link:hover,
.theme-reply-detail-delete-form .button-link:hover {
    color: var(--color-ink);
}

.theme-reply-thread-title strong {
    overflow: hidden;
    min-width: 0;
    color: var(--color-ink);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.theme-reply-thread-title span {
    flex: 0 0 auto;
    color: var(--color-muted);
    font-size: 12px;
}

.theme-reply-thread-body {
    --reply-content-image-default-width: clamp(72px, 11vw, 88px);
    --reply-content-image-inline-gap: 4px;

    font-size: 14px;
    line-height: 1.7;
}

.theme-reply-detail-comments {
    display: grid;
    min-width: 0;
    gap: 6px;
    margin-top: 2px;
}

.theme-reply-detail-comment-list {
    display: grid;
    min-width: 0;
}

.theme-reply-detail-comment-pager {
    justify-content: flex-end;
    margin-top: 0;
}

.theme-reply-detail-comment-pager[hidden],
.theme-reply-detail-comment[hidden] {
    display: none;
}

.theme-reply-detail-comment {
    display: grid;
    gap: 6px;
    min-width: 0;
    border-bottom: 1px solid var(--color-hairline);
    background: transparent;
    padding: 12px 0 5px;
}

.theme-reply-detail-comment:first-child {
    padding-top: 8px;
}

.theme-reply-detail-comment:last-child {
    border-bottom: 1px solid var(--color-hairline);
}

.theme-reply-detail-comment-head {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 8px;
}

.theme-reply-detail-comment-avatar,
.theme-reply-detail-comment-avatar-media {
    display: inline-flex;
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.theme-reply-detail-comment-avatar-media {
    background: var(--color-surface-strong);
    color: var(--color-ink);
    font-size: 11px;
    font-weight: 600;
    object-fit: cover;
}

.theme-reply-detail-comment-body {
    --reply-content-image-default-width: clamp(72px, 11vw, 88px);
    --reply-content-image-inline-gap: 4px;

    font-size: 13px;
    line-height: 1.65;
}

.theme-reply-form {
    margin-top: 0;
    padding-top: 22px;
    border-top: 0;
}

.theme-reply-form .button-primary {
    color: var(--theme-button-accent);
}

.theme-reply-compose-shell {
    position: fixed;
    z-index: 45;
    left: max(20px, calc((100vw - var(--theme-page-wide-width)) / 2));
    bottom: calc(14px + var(--reply-compose-footer-offset, 0px) + env(safe-area-inset-bottom));
    width: min(1056px, calc(100vw - 384px));
    color: var(--color-ink);
}

.theme-reply-compose {
    width: 100%;
    color: inherit;
}

.theme-reply-compose[open] {
    width: 100%;
}

.theme-reply-compose-summary {
    position: absolute;
    overflow: hidden;
    width: 1px;
    height: 1px;
    clip-path: inset(50%);
    list-style: none;
    white-space: nowrap;
}

.theme-reply-compose-summary::-webkit-details-marker {
    display: none;
}

.theme-reply-compose-summary-text {
    font-size: 14px;
    font-weight: 600;
}

.theme-reply-compose-summary-hint {
    color: var(--color-muted);
    font-size: 12px;
}

.theme-reply-compose[open] > .theme-reply-compose-summary {
    display: none;
}

.theme-reply-compose-mini-form {
    display: flex;
    min-height: 52px;
    align-items: flex-end;
    gap: 6px;
    border-radius: var(--radius-md);
    background: var(--color-surface);
    box-shadow: var(--shadow-soft);
    padding: 6px;
}

.theme-reply-compose[open] + .theme-reply-compose-mini-form {
    display: none;
}

.theme-reply-compose-mini-input {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 40px;
    max-height: 96px;
    resize: none;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-ink);
    font: inherit;
    font-size: 14px;
    line-height: 1.45;
    outline: 0;
    padding: 10px 12px;
}

.theme-reply-compose-mini-input::placeholder {
    color: var(--color-muted);
}

.theme-reply-compose-expand,
.theme-reply-compose-mini-submit {
    flex: 0 0 auto;
    min-width: 52px;
    min-height: 40px;
    border-radius: var(--radius-button);
    font-size: 13px;
    line-height: 1;
    padding: 0 12px;
}

.theme-reply-compose-expand {
    cursor: pointer;
}

.theme-reply-compose-panel {
    display: grid;
    max-height: min(72vh, 560px);
    overflow: auto;
    gap: 14px;
    border-radius: var(--radius-md);
    background: var(--color-surface);
    box-shadow: var(--shadow-soft);
    overscroll-behavior: contain;
    padding: 14px;
}

.theme-reply-compose-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--color-ink);
    font-size: 14px;
    font-weight: 600;
}

.theme-reply-compose-close {
    --theme-edge-button-line-inset-x: 5px;
    --theme-edge-button-line-inset-y: 4px;
    color: var(--theme-button-accent);
}

.theme-reply-compose-close:hover,
.theme-reply-compose-close:focus-visible {
    color: var(--theme-button-accent);
}

.theme-reply-compose-form {
    display: grid;
    gap: 12px;
    padding-top: 0;
}

.theme-reply-compose-form label {
    margin-bottom: 0;
}

.theme-reply-compose-form textarea {
    min-height: 132px;
}

.theme-reply-compose-form .msx-editor-surface {
    min-height: 132px;
}

.theme-reply-compose-form .content-image-uploader {
    margin: 0;
}

.theme-reply-compose-form .button-primary {
    justify-self: end;
}

.theme-reply-login-floating {
    display: inline-flex;
    width: 100%;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-pill);
    background: var(--color-surface);
    box-shadow: var(--shadow-soft);
    color: var(--color-ink);
    padding: 0 16px;
    font-size: 14px;
    font-weight: 600;
}

.theme-reply-child-form {
    display: grid;
    gap: 12px;
    padding-top: 16px;
}

.theme-reply-thread-root > .theme-reply-child-form:first-child,
.theme-reply-detail-comments + .theme-reply-child-form {
    padding-top: 0;
}

.theme-reply-child-form label {
    margin-bottom: 0;
}

.theme-reply-child-form textarea {
    min-height: 112px;
}

.theme-reply-child-form .content-image-uploader {
    margin: 0;
}

.theme-reply-child-form .button-primary {
    width: fit-content;
}

.theme-reply-login,
.theme-reply-empty {
    margin: 0;
}

@media (max-width: 720px) {
    .theme-reply-panel {
        padding: 12px;
    }

    .theme-reply-compose-shell {
        left: 8px;
        bottom: calc(8px + var(--reply-compose-footer-offset, 0px) + env(safe-area-inset-bottom));
        width: calc(100vw - 16px);
    }

    .theme-reply-compose-mini-form {
        min-height: 48px;
        padding: 5px;
    }

    .theme-reply-compose-mini-input {
        min-height: 38px;
        padding: 9px 10px;
    }

    .theme-reply-compose-expand,
    .theme-reply-compose-mini-submit {
        min-width: 48px;
        min-height: 38px;
        padding: 0 10px;
    }

    .theme-reply-login-floating {
        justify-content: center;
    }

    .theme-reply-compose-panel {
        max-height: min(78vh, 560px);
        padding: 12px;
    }

    .theme-reply-item {
        gap: 10px;
    }

    .theme-reply-floor-head {
        padding-right: 76px;
    }

    .theme-reply-avatar-link,
    .theme-reply-avatar-link img,
    .theme-reply-avatar-link span {
        width: 34px;
        height: 34px;
    }

    .theme-reply-chip {
        max-width: min(320px, calc((100% - var(--reply-chip-row-gap)) / 2));
        border-radius: var(--radius-md);
    }

    .theme-reply-chip-text {
        max-width: 100%;
    }

    .theme-reply-drawer {
        width: calc(100vw - 6px);
    }
}
