/* 详情页评论区核心布局与高密度讨论流（适配原本机器人 SVG / 自定义头像系统） */
.rx-comments {
    position: relative;
    overflow: hidden;
    padding: 20px 24px 22px;
    margin-bottom: 22px;
    --rx-c-body: #c7d1e0;
    --rx-c-sub-bg: rgba(255, 255, 255, .032);
    --rx-c-line-soft: rgba(170, 189, 220, .095);
    --rx-c-input-bg: rgba(7, 12, 20, .46);
    --rx-c-gold: #f5b94c;
    --rx-c-gold-bg: rgba(245, 185, 76, .12);
    --rx-c-gold-border: rgba(245, 185, 76, .28);
    --rx-c-like: #ff7c92;
    --rx-c-seg-active: rgba(17, 22, 31, .92);
}

/* 宽屏下 html(0.9) * .rx-shell(1.25) = 1.125x；此处设 0.9 使评论区落在舒适的 ~1.01x 黄金尺度 */
@media (min-width: 1025px) {
    body.rx-detail-page .rx-shell .rx-comments {
        zoom: 0.9;
    }
}

.rx-comments::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 115px;
    pointer-events: none;
    background: radial-gradient(85% 100% at 8% 0, rgba(75, 141, 255, .09), transparent 70%);
}
.rx-comments > * {
    position: relative;
}

/* 顶部紧凑单行标题与真功能工具栏 */
.rx-c-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding-bottom: 13px;
    border-bottom: 1px solid var(--rx-c-line-soft);
}
.rx-c-title-wrap {
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.rx-c-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -.01em;
    color: var(--rx-text);
}
.rx-c-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--rx-muted);
    font-variant-numeric: tabular-nums;
}
.rx-c-tools {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.rx-c-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 29px;
    padding: 0 11px;
    border: 1px solid var(--rx-line);
    border-radius: 7px;
    background: transparent;
    color: var(--rx-muted);
    font-size: 12.5px;
    line-height: 1;
    transition: color .15s ease, border-color .15s ease, background-color .15s ease;
}
.rx-c-filter-btn svg {
    width: 12.5px;
    height: 12.5px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.rx-c-filter-btn b {
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}
.rx-c-filter-btn:hover {
    color: var(--rx-text);
    border-color: rgba(75, 141, 255, .45);
}
.rx-c-filter-btn.is-active {
    color: var(--rx-c-gold);
    border-color: var(--rx-c-gold-border);
    background: var(--rx-c-gold-bg);
    font-weight: 600;
}
.rx-c-seg {
    display: inline-flex;
    padding: 2px;
    border: 1px solid var(--rx-line);
    border-radius: 7px;
    background: var(--rx-panel-soft);
}
.rx-c-seg button {
    border: 0;
    background: transparent;
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 12.5px;
    line-height: 1.3;
    color: var(--rx-muted);
    transition: color .15s ease, background-color .15s ease;
}
.rx-c-seg button:hover {
    color: var(--rx-text);
}
.rx-c-seg button.is-active {
    background: var(--rx-c-seg-active);
    color: var(--rx-text);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}

/* 主楼讨论流：去重卡片，纯细分割线 */
.rx-comments .rx-feed {
    list-style: none;
    margin: 0;
    padding: 0;
}
.rx-comments .rx-feed[hidden] {
    display: none;
}
.rx-thread {
    list-style: none;
    padding: 13px 0;
    border-bottom: 1px solid var(--rx-c-line-soft);
}
.rx-thread[hidden] {
    display: none;
}
.rx-thread:last-child {
    border-bottom: 0;
    padding-bottom: 2px;
}
.rx-row {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 11px;
    align-items: start;
}
.rx-row-main {
    min-width: 0;
}

/* 完整兼容原本头像系统（DiceBear 机器人 SVG 库与自定义头像），消除全局 .avatar 浮动污染 */
.rx-row-av,
.rx-composer-av {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--rx-panel-soft);
    border: 1px solid rgba(180, 207, 255, .22);
}
.rx-sub-av {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    margin-top: 2px;
    background: var(--rx-panel-soft);
    border: 1px solid rgba(180, 207, 255, .2);
}
.rx-comments img.avatar,
.rx-comments img.rx-comment-avatar,
.rx-comments img.gr-library-avatar {
    float: none;
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    object-fit: cover;
}
.rx-comment-avatar-fallback {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(145deg, var(--rx-avatar-a, #4a8cff), var(--rx-avatar-b, #254cae));
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    user-select: none;
}
.rx-comment-avatar-sm.rx-comment-avatar-fallback {
    font-size: 10.5px;
}

/* 单行元信息 */
.rx-c-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    line-height: 1.35;
}
.rx-c-author {
    font-size: 13.5px;
    font-weight: 650;
    color: var(--rx-text);
}
.rx-c-author a {
    color: inherit;
    text-decoration: none;
}
.rx-c-author a:hover {
    color: var(--rx-blue);
}
.rx-c-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    height: 18px;
    padding: 0 6px;
    border-radius: 4px;
    font-size: 10.5px;
    font-weight: 650;
    line-height: 1;
    white-space: nowrap;
}
.rx-c-badge-admin {
    color: #291b04;
    background: linear-gradient(135deg, #ffe5a5, #f5b94c);
    border: 1px solid rgba(255, 224, 151, .55);
}
.rx-c-badge-admin svg {
    width: 10.5px;
    height: 10.5px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.rx-c-badge-lv {
    color: #9ec2ff;
    background: rgba(75, 141, 255, .12);
    border: 1px solid rgba(100, 157, 255, .2);
}
.rx-c-badge-lv[data-level="3"],
.rx-c-badge-lv[data-level="4"] {
    color: #7ee2cc;
    background: rgba(78, 216, 183, .11);
    border-color: rgba(78, 216, 183, .22);
}
.rx-c-badge-lv[data-level="5"],
.rx-c-badge-lv[data-level="6"] {
    color: #ffd486;
    background: rgba(255, 196, 87, .12);
    border-color: rgba(255, 196, 87, .24);
}
.rx-c-time {
    font-size: 12px;
    color: var(--rx-muted);
    font-variant-numeric: tabular-nums;
}

/* 正文与长评折行 */
.rx-c-body {
    margin-top: 5px;
    font-size: 14px;
    line-height: 1.62;
    color: var(--rx-c-body);
    overflow-wrap: anywhere;
}
.rx-c-body > p {
    margin: 0 0 6px;
}
.rx-c-body > p:last-child {
    margin-bottom: 0;
}
.rx-c-body a {
    color: var(--rx-blue);
}
.rx-c-body.is-clamped {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.rx-c-expand-text {
    display: inline-block;
    margin-top: 3px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--rx-blue);
    font-size: 12.5px;
    font-weight: 550;
}
.rx-c-expand-text:hover {
    text-decoration: underline;
}
.rx-c-awaiting {
    margin: 4px 0 0;
    color: var(--rx-c-gold);
    font-size: 12px;
}

/* 空状态 */
.rx-c-empty {
    padding: 22px 16px;
    text-align: center;
    color: var(--rx-muted);
    font-size: 13px;
    border: 1px dashed var(--rx-line);
    border-radius: 10px;
    margin-top: 10px;
}
.rx-c-empty[hidden] {
    display: none;
}

/* 浅色模式精准高对比度适配 */
html:not([data-theme="dark"]) .rx-comments {
    --rx-c-body: #334155;
    --rx-c-sub-bg: rgba(15, 23, 42, .034);
    --rx-c-line-soft: rgba(148, 163, 184, .22);
    --rx-c-input-bg: rgba(255, 255, 255, .94);
    --rx-c-gold: #a16207;
    --rx-c-gold-bg: rgba(245, 158, 11, .11);
    --rx-c-gold-border: rgba(217, 119, 6, .3);
    --rx-c-like: #e11d48;
    --rx-c-seg-active: #ffffff;
}
html:not([data-theme="dark"]) .rx-row-av,
html:not([data-theme="dark"]) .rx-composer-av,
html:not([data-theme="dark"]) .rx-sub-av {
    border-color: rgba(148, 163, 184, .35);
    background: #eef2f7;
}
html:not([data-theme="dark"]) .rx-c-badge-lv {
    color: #214d91;
    background: rgba(37, 99, 235, .09);
    border-color: rgba(37, 99, 235, .2);
}
html:not([data-theme="dark"]) .rx-c-badge-lv[data-level="3"],
html:not([data-theme="dark"]) .rx-c-badge-lv[data-level="4"] {
    color: #0d5b4e;
    background: rgba(16, 185, 129, .1);
    border-color: rgba(16, 185, 129, .24);
}
html:not([data-theme="dark"]) .rx-c-badge-lv[data-level="5"],
html:not([data-theme="dark"]) .rx-c-badge-lv[data-level="6"] {
    color: #7c4a03;
    background: rgba(245, 158, 11, .12);
    border-color: rgba(217, 119, 6, .26);
}
html:not([data-theme="dark"]) .rx-c-seg button.is-active {
    box-shadow: 0 1px 3px rgba(15, 23, 42, .1);
}

/* 移动端适配（保留相对时间，不溢出） */
@media (max-width: 760px) {
    .rx-comments {
        padding: 15px 15px 18px;
        border-radius: 13px;
        margin-bottom: 17px;
    }
    .rx-c-head {
        gap: 8px;
        padding-bottom: 11px;
    }
    .rx-c-title {
        font-size: 16px;
    }
    .rx-row {
        grid-template-columns: 30px minmax(0, 1fr);
        gap: 10px;
    }
    .rx-row-av,
    .rx-composer-av {
        width: 30px;
        height: 30px;
    }
    .rx-c-body {
        font-size: 13.5px;
    }
}
