/* ==========================================================================
   comment.css —— 评论 UI 的唯一业务样式层
   ==========================================================================

   为什么放在项目根的 static/ 而不是某个 app：
     首页（app_picllery）与个人页沉浸查看器（app_users）各有一套评论面板，
     两页不共载页面 CSS。放在任一 app 都会让另一页反向依赖它。根 static/
     是项目预留的跨 app 共享目录（dialog.css / dialog.js 已在这里）。

   加载顺序铁律：dialog.css → comment.css → 页面 CSS（index.css / profile.css）。
     comment.css 只写 .cmt-* 与评论面板自己的 --cmt-* token；旧 .comment-* /
     .immersive-comment-* 规则必须从页面 CSS 删除，否则它们晚于本文件加载、
     同特异性，会把新样式静默压回去。

   形态：沿用 .dlg-scrim + .dlg-panel.dlg-panel--fill 的底部抽屉，不改弹窗基类。
   显隐唯一真相源仍是 [aria-hidden]（dialog.js）；本文件只管内容。

   ⚠️ 本文件不得出现「静态资源引用」语法（注释里也不行）：
      Django 的 ManifestStaticFilesStorage 大小写不敏感地解析它，
     注释里的同样会导致 collectstatic 中断（2026-10-11 事故）。
     本文件的 Noto Emoji 全部走 `<img>`，CSS 里没有任何静态资源引用。
   ========================================================================== */

:root {
    /* ---- 尺寸 ---- */
    --cmt-avatar: 36px;
    --cmt-avatar-reply: 24px;
    --cmt-gap: 10px;              /* 头像与正文 */
    --cmt-row-gap: 14px;          /* 评论行之间的呼吸 */
    --cmt-radius: 12px;
    --cmt-pill-h: 30px;
    --cmt-hit: 44px;
    --cmt-fold-lines: 5;
    --cmt-emoji-tile: 32px;
    --cmt-emoji-img: 22px;

    /* ---- 颜色：只在本块定义，正文规则一律 var() ---- */
    --cmt-surface-soft: #f6f8f7;
    --cmt-surface-pill: #f4f5f7;
    --cmt-surface-pill-active: #ebedec;
    --cmt-time: #8a8a8a;
    --cmt-brand: var(--dlg-brand);
    --cmt-brand-soft: rgba(152, 224, 172, 0.18);
    --cmt-danger: var(--dlg-danger-ink);
    --cmt-danger-soft: var(--dlg-danger-soft-bg);
    --cmt-mention: #2f7d4f;
    --cmt-count-warn: #b26a00;
}

/* ==========================================================================
   面板：栅格与左右安全区
   ==========================================================================
   底部安全区仍只由 .dlg-panel 承担（dialog.css），这里绝不重复。
   左右安全区作用于面板自身：横屏刘海机上面板铺满 100vw，16px 栅格会落进
   刘海区；env() 在竖屏恒为 0，不影响任何现有页面。 */
.comment-sheet,
.immersive-comment-sheet {
    --dlg-gutter: 16px;
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

@media only screen and (max-width: 360px) {
    .comment-sheet,
    .immersive-comment-sheet {
        --dlg-gutter: 12px;
    }
}

@media only screen and (min-width: 651px) {
    .comment-sheet,
    .immersive-comment-sheet {
        --dlg-gutter: 20px;
    }
}

/* ==========================================================================
   列表与评论行
   ========================================================================== */

.cmt-list {
    /* 同时挂 .dlg-body：overflow-y / touch-action / 弹性高度全部继承基类，
       这里只覆盖 padding（comment.css 晚于 dialog.css，同特异性可覆盖）。 */
    display: flex;
    flex-direction: column;
    padding: 4px var(--dlg-gutter) 12px;
    overscroll-behavior: contain;
}

.cmt-item {
    flex: 0 0 auto;
    display: flex;
    gap: var(--cmt-gap);
    /* 负外边距 + 等量内边距：hover 底色横向逃逸到 gutter 边缘，但内容仍与
       .dlg-title 左缘对齐（P76 手法）。width 必须 auto（不能 100%）。 */
    width: auto;
    margin: 0 -8px;
    padding: 10px 8px;
    border-radius: var(--cmt-radius);
    /* 无 border：清爽留白靠间距分层 */
}

.cmt-item + .cmt-item {
    margin-top: var(--cmt-row-gap);
}

/* 回复目标：只改背景，不碰 margin/padding —— 旧实现会位移 8px */
.cmt-item.is-reply-target {
    background: var(--cmt-brand-soft);
}

/* 置顶行左侧 3px 品牌绿条；位置在行 padding 区，不压头像。 */
.cmt-item.is-pinned {
    position: relative;
}

.cmt-item.is-pinned::before {
    content: "";
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 999px;
    background: var(--cmt-brand);
}

/* 深链定位行的短暂高亮；hover 规则会排除它，见文末 hover 块。 */
.cmt-item.is-focus-target {
    background: var(--cmt-brand-soft);
    box-shadow: inset 0 0 0 2px var(--cmt-brand);
}

.cmt-avatar-link {
    flex: 0 0 var(--cmt-avatar);
    width: var(--cmt-avatar);
    height: var(--cmt-avatar);
    border-radius: 50%;
    overflow: hidden;
    text-decoration: none;
    /* 命中区 = 视觉尺寸：它紧贴正文列，撑到 44px 会覆盖文字左缘造成误跳 */
}

.cmt-avatar-link[aria-disabled="true"] {
    cursor: default;
}

.cmt-avatar {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 50%;
    object-fit: cover;
    background: var(--cmt-surface-soft);
}

.cmt-main {
    flex: 1 1 auto;
    min-width: 0;
}

.cmt-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 8px;
    font-size: var(--dlg-font-caption);
    color: var(--cmt-time);
    line-height: 1.4;
}

.cmt-author {
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--dlg-font-label);
    font-weight: 600;
    color: var(--dlg-text);
}

.cmt-official {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
}

.cmt-official svg {
    width: 14px;
    height: 14px;
    display: block;
}

/* 置顶徽章：白底 + 品牌绿描边，在白色行与 .is-reply-target 的浅绿底上都可见。
   不写死 height：字号放大时用 min-height + padding 撑开，避免裁切。 */
.cmt-pin-badge {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    min-height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--dlg-surface);
    box-shadow: inset 0 0 0 1px var(--cmt-brand);
    color: var(--cmt-mention);
    font-size: var(--dlg-font-caption);
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

/* 作者标识：中性灰 chip，刻意与绿色置顶徽章区分。 */
.cmt-owner-badge {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    min-height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--cmt-surface-pill);
    color: var(--dlg-text-dim);
    font-size: var(--dlg-font-caption);
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

.cmt-time,
.cmt-edited,
.cmt-reply-to {
    flex: 0 0 auto;
    color: var(--cmt-time);
    font-size: var(--dlg-font-caption);
}

.cmt-reply-to {
    max-width: 40%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cmt-content {
    margin-top: 3px;
    font-size: var(--dlg-font-body);
    line-height: 1.55;
    color: var(--dlg-text);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    /* 首页 body 有 * { user-select: none }；评论正文允许选中/长按复制 */
    user-select: text;
    -webkit-user-select: text;
}

.cmt-content.is-deleted {
    color: var(--cmt-time);
}

.cmt-content.is-collapsed {
    max-height: calc(var(--cmt-fold-lines) * 1.55em);
    overflow: hidden;
}

.cmt-mention {
    color: var(--cmt-mention);
    font-weight: 500;
}

.cmt-emoji {
    width: 1.25em;
    height: 1.25em;
    max-width: none;
    vertical-align: -0.22em;
    margin: 0 1px;
}

/* ==========================================================================
   动作行：图标 + 文字的小胶囊
   ========================================================================== */

.cmt-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.cmt-action,
.cmt-vote,
.cmt-fold,
.cmt-more-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 36px;
    height: var(--cmt-pill-h);
    padding: 0 10px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--dlg-text-dim);
    font-size: var(--dlg-font-caption);
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* 只扩纵向：横向若也扩，相邻胶囊的命中区会互相重叠 */
.cmt-action::before,
.cmt-vote::before,
.cmt-fold::before,
.cmt-more-item::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: var(--cmt-hit);
    transform: translateY(-50%);
}

.cmt-action svg,
.cmt-vote svg,
.cmt-fold svg {
    width: 16px;
    height: 16px;
    display: block;
    flex: 0 0 auto;
}

.cmt-vote {
    padding: 0 8px;
    background: var(--cmt-surface-pill);
}

.cmt-vote svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.cmt-vote-count {
    min-width: 10px;
    text-align: left;
    font-variant-numeric: tabular-nums;
}

.cmt-vote[aria-pressed="true"] {
    color: var(--dlg-text);
}

.cmt-vote--up[aria-pressed="true"] {
    background: var(--cmt-brand-soft);
}

.cmt-vote--up[aria-pressed="true"] svg {
    fill: var(--cmt-brand);
    stroke: var(--cmt-brand);
}

.cmt-vote--down[aria-pressed="true"] {
    background: var(--cmt-danger-soft);
}

.cmt-vote--down[aria-pressed="true"] svg {
    fill: var(--cmt-danger);
    stroke: var(--cmt-danger);
}

.cmt-fold {
    margin-top: 2px;
    padding: 0 8px;
    color: var(--cmt-time);
}

.cmt-more-item {
    background: var(--cmt-surface-pill);
}

.cmt-more-item--danger {
    color: var(--cmt-danger);
}

.cmt-actions .cmt-more {
    margin-left: auto;
    min-width: var(--cmt-hit);
    padding: 0 6px;
    font-size: var(--dlg-font-body);
    letter-spacing: 1px;
}

.cmt-more-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.cmt-edit {
    margin-top: 6px;
}

.cmt-edit-input {
    width: 100%;
    box-sizing: border-box;
    resize: none;
    border: 1px solid var(--dlg-border);
    border-radius: 10px;
    padding: 8px 10px;
    font-family: inherit;
    line-height: 1.4;
    background: #fafafa;
    color: var(--dlg-text);
    outline: none;
    user-select: text;
    -webkit-user-select: text;
    touch-action: auto;
}

.cmt-edit-input:focus {
    border-color: #c9d6ce;
    background: #ffffff;
}

.cmt-edit-meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
    font-size: var(--dlg-font-caption);
    color: var(--cmt-time);
}

.cmt-edit-error {
    color: var(--cmt-danger);
    text-align: right;
}

.cmt-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 6px;
}

.cmt-edit-save {
    background: var(--cmt-brand);
    color: var(--dlg-on-brand);
    font-weight: 600;
}

.cmt-edit-save:disabled {
    background: #bdbdbd;
    color: #ffffff;
    cursor: not-allowed;
}

.cmt-item.is-editing .cmt-content,
.cmt-item.is-editing .cmt-fold,
.cmt-item.is-editing .cmt-actions,
.cmt-item.is-editing .cmt-more-row {
    display: none;
}

/* 删除二次确认 */
.cmt-delete-confirm {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 4px;
    border-radius: 999px;
    background: var(--cmt-danger-soft);
    animation: cmt-confirm-in 0.15s ease;
}

.cmt-delete-confirm-btn,
.cmt-delete-confirm-cancel {
    min-height: 32px;
    padding: 0 10px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    font-size: var(--dlg-font-caption);
    cursor: pointer;
}

.cmt-delete-confirm-btn {
    color: var(--cmt-danger);
    font-weight: 600;
}

.cmt-delete-confirm-cancel {
    color: var(--dlg-text-dim);
}

@keyframes cmt-confirm-in {
    from { opacity: 0; transform: scale(0.94); }
    to   { opacity: 1; transform: scale(1); }
}

/* ==========================================================================
   回复区
   ========================================================================== */

.cmt-replies {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: var(--cmt-radius);
    background: var(--cmt-surface-soft);
}

.cmt-item--reply {
    margin: 0;
    padding: 6px 0;
    gap: 8px;
    border-radius: 8px;
}

.cmt-item--reply + .cmt-item--reply {
    margin-top: 0;
}

.cmt-item--reply .cmt-avatar-link {
    flex: 0 0 var(--cmt-avatar-reply);
    width: var(--cmt-avatar-reply);
    height: var(--cmt-avatar-reply);
}

.cmt-item--reply .cmt-author {
    font-size: var(--dlg-font-caption);
}

.cmt-item--reply .cmt-content {
    font-size: var(--dlg-font-body);
    line-height: 1.5;
}

.cmt-replies-more {
    align-self: flex-start;
    min-height: 32px;
    margin-top: 2px;
    padding: 0 8px;
    border: 0;
    background: transparent;
    color: var(--dlg-text-dim);
    font-size: var(--dlg-font-caption);
    cursor: pointer;
}

/* ==========================================================================
   空态 / 加载更多 / 骨架 / 错误
   ==========================================================================
   空态与加载更多是 .dlg-panel 的 flex 子项（列表的兄弟）：
   如果放进列表，任何 innerHTML = '' 与排序缓存还原都会把它们清掉。 */
.cmt-empty {
    flex: 1 1 auto;
    min-height: min(160px, 30vh);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 24px var(--dlg-gutter);
    text-align: center;
}

.cmt-empty-icon {
    width: 44px;
    height: 44px;
    margin-bottom: 4px;
    color: #c7d0cb;
}

.cmt-empty-title {
    margin: 0;
    font-size: var(--dlg-font-body);
    font-weight: 600;
    color: var(--dlg-text);
}

.cmt-empty-sub {
    margin: 0;
    font-size: var(--dlg-font-label);
    color: var(--cmt-time);
}

.cmt-load-more {
    flex: 0 0 auto;
    align-self: center;
    position: relative;
    min-height: 34px;
    margin: 6px 0 4px;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    background: var(--cmt-surface-pill);
    color: var(--dlg-text-dim);
    font-size: var(--dlg-font-label);
    font-weight: 500;
    cursor: pointer;
}

.cmt-load-more::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: var(--cmt-hit);
    transform: translateY(-50%);
}

.cmt-skeleton {
    display: flex;
    gap: var(--cmt-gap);
    padding: 10px 0;
}

.cmt-skeleton-avatar {
    flex: 0 0 var(--cmt-avatar);
    width: var(--cmt-avatar);
    height: var(--cmt-avatar);
    border-radius: 50%;
    background: #f0f0f0;
}

.cmt-skeleton-lines {
    flex: 1 1 auto;
    min-width: 0;
}

.cmt-skeleton-line {
    height: 10px;
    margin-bottom: 6px;
    border-radius: 6px;
    background: #f2f2f2;
    background-image: linear-gradient(90deg, #f2f2f2 0%, #f8f8f8 50%, #f2f2f2 100%);
    background-size: 200% 100%;
    animation: cmt-shimmer 1.4s ease infinite;
}

.cmt-skeleton-line--long { width: 70%; }
.cmt-skeleton-line--short { width: 40%; }

@keyframes cmt-shimmer {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}

.cmt-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 28px 16px;
    text-align: center;
    color: var(--dlg-text-dim);
    font-size: var(--dlg-font-body);
}

.cmt-error-retry {
    min-height: 36px;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    background: var(--cmt-surface-pill);
    color: var(--dlg-text);
    font-size: var(--dlg-font-label);
    cursor: pointer;
}

/* ==========================================================================
   编辑器
   ========================================================================== */

.cmt-editor {
    border-top: 1px solid #f2f2f2;
}

.cmt-reply-hint {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
    padding: 6px 4px 6px 10px;
    border-radius: 10px;
    background: var(--cmt-brand-soft);
    color: var(--dlg-text);
    font-size: var(--dlg-font-caption);
}

.cmt-reply-hint-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cmt-reply-cancel {
    position: relative;
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--dlg-text-dim);
    font-size: var(--dlg-font-title);
    line-height: 1;
    cursor: pointer;
}

.cmt-reply-cancel::before {
    content: "";
    position: absolute;
    inset: -8px;
}

/* 输入框为空时 placeholder 已经显示「回复 @xxx」——提示条文字再写一遍就是重复。
   此时把提示条收成右侧一个 × 取消按钮；开始输入后 placeholder 消失，文字才出现。 */
.cmt-editor:has(.cmt-input:placeholder-shown) .cmt-reply-hint {
    justify-content: flex-end;
    margin-bottom: 2px;
    padding: 0;
    background: transparent;
}

.cmt-editor:has(.cmt-input:placeholder-shown) .cmt-reply-hint-text {
    display: none;
}

.cmt-compose {
    position: relative;
    box-sizing: border-box;
    padding: 8px 10px 6px;
    border: 1px solid transparent;
    border-radius: var(--cmt-radius);
    background: var(--cmt-surface-soft);
}

.cmt-compose:focus-within {
    border-color: var(--dlg-border);
    background: #ffffff;
    box-shadow: var(--dlg-focus-ring);
}

.cmt-input-wrap {
    position: relative;
}

.cmt-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 0;
    border: 0;
    outline: none;
    resize: none;
    background: transparent;
    color: var(--dlg-text);
    font-family: inherit;
    line-height: 1.4;
    overflow-y: hidden;
    /* 首页 body 有 touch-action: none 与全局 user-select: none */
    user-select: text;
    -webkit-user-select: text;
    touch-action: auto;
}

.cmt-input::placeholder {
    font-size: var(--dlg-font-label);
    color: #9a9a9a;
}

.cmt-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.cmt-count {
    font-size: var(--dlg-font-caption);
    color: var(--cmt-time);
    font-variant-numeric: tabular-nums;
}

.cmt-count.is-warn {
    color: var(--cmt-count-warn);
}

.cmt-count.is-limit {
    color: var(--cmt-danger);
}

.cmt-hotkey {
    display: none;
    font-size: var(--dlg-font-caption);
    color: #9a9a9a;
    white-space: nowrap;
}

.cmt-submit {
    margin-left: auto;
    min-height: 32px;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    background: var(--cmt-brand);
    color: var(--dlg-on-brand);
    font-size: var(--dlg-font-label);
    font-weight: 600;
    cursor: pointer;
}

.cmt-submit:disabled {
    background: #bdbdbd;
    color: #ffffff;
    cursor: not-allowed;
}

.cmt-emoji-btn {
    position: relative;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cmt-emoji-btn::before {
    content: "";
    position: absolute;
    inset: -6px;
}

.cmt-emoji-btn img {
    width: 22px;
    height: 22px;
    display: block;
}

/* ---- 表情面板 ---- */
.cmt-emoji-panel {
    position: absolute;
    left: 0;
    bottom: calc(100% + 6px);
    box-sizing: border-box;
    max-width: calc(100vw - 24px);
    max-height: min(320px, 45vh);
    padding: 8px;
    overflow-y: auto;
    touch-action: pan-y;
    overscroll-behavior: contain;
}

.cmt-emoji-recent {
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.cmt-emoji-label {
    margin: 0 0 4px;
    font-size: var(--dlg-font-caption);
    color: var(--cmt-time);
}

.cmt-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, var(--cmt-emoji-tile));
    gap: 6px;
}

.cmt-emoji-item {
    position: relative;
    box-sizing: border-box;
    width: var(--cmt-emoji-tile);
    height: var(--cmt-emoji-tile);
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cmt-emoji-item img {
    width: var(--cmt-emoji-img);
    height: var(--cmt-emoji-img);
    display: block;
}

/* ---- @ 候选 ---- */
.cmt-mention-pop {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 6px);
    box-sizing: border-box;
    max-height: min(220px, 40vh);
    padding: 4px;
    overflow-y: auto;
    touch-action: pan-y;
    overscroll-behavior: contain;
}

.cmt-mention-option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: var(--cmt-hit);
    padding: 0 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--dlg-text);
    font-size: var(--dlg-font-body);
    text-align: left;
    cursor: pointer;
}

.cmt-mention-option img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 24px;
}

.cmt-mention-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cmt-mention-handle {
    margin-left: auto;
    color: var(--cmt-time);
    font-size: var(--dlg-font-caption);
    white-space: nowrap;
}

/* ==========================================================================
   交互态
   ========================================================================== */

@media (hover: hover) {
    .cmt-action:hover,
    .cmt-fold:hover,
    .cmt-more-item:hover,
    .cmt-replies-more:hover,
    .cmt-emoji-item:hover,
    .cmt-mention-option:hover {
        background: var(--cmt-surface-pill-active);
        color: var(--dlg-text);
    }

    .cmt-vote:hover {
        background: var(--cmt-surface-pill-active);
        color: var(--dlg-text);
    }

    .cmt-item:not(.cmt-item--reply):not(.is-reply-target):not(.is-focus-target):hover {
        background: var(--dlg-hover);
    }

    .cmt-emoji-btn:hover {
        background: var(--dlg-hover);
    }
}

.cmt-action:active,
.cmt-vote:active,
.cmt-fold:active,
.cmt-more-item:active,
.cmt-emoji-item:active,
.cmt-emoji-btn:active,
.cmt-submit:active:not(:disabled) {
    transform: scale(0.96);
}

.cmt-action:focus-visible,
.cmt-vote:focus-visible,
.cmt-fold:focus-visible,
.cmt-more-item:focus-visible,
.cmt-replies-more:focus-visible,
.cmt-load-more:focus-visible,
.cmt-error-retry:focus-visible,
.cmt-emoji-item:focus-visible,
.cmt-emoji-btn:focus-visible,
.cmt-submit:focus-visible,
.cmt-reply-cancel:focus-visible,
.cmt-edit-save:focus-visible,
.cmt-edit-cancel:focus-visible,
.cmt-delete-confirm-btn:focus-visible,
.cmt-delete-confirm-cancel:focus-visible,
.cmt-mention-option:focus-visible {
    outline: none;
    box-shadow: var(--dlg-focus-ring);
}

/* ==========================================================================
   断点：尺寸走 token 覆盖
   ========================================================================== */

@media only screen and (max-width: 360px) {
    :root {
        --cmt-avatar: 32px;
        --cmt-avatar-reply: 22px;
        --cmt-gap: 8px;
        --cmt-row-gap: 12px;
        --cmt-pill-h: 28px;
        --cmt-emoji-tile: 36px;
        --cmt-emoji-img: 24px;
    }

    .cmt-actions,
    .cmt-more-row {
        gap: 4px;
    }

    .cmt-emoji-grid {
        grid-template-columns: repeat(6, var(--cmt-emoji-tile));
    }
}

@media only screen and (min-width: 651px) {
    :root {
        --cmt-avatar: 40px;
        --cmt-avatar-reply: 26px;
        --cmt-row-gap: 18px;
        --cmt-emoji-tile: 36px;
        --cmt-emoji-img: 26px;
    }
}

/* 桌面才显示快捷键提示；触屏/窄屏不占位置 */
@media only screen and (min-width: 361px) and (hover: hover) and (pointer: fine) {
    .cmt-hotkey {
        display: inline;
    }
}

/* ==========================================================================
   短视口 / 键盘
   ==========================================================================
   ⚠️ dialog.css 在 @media (max-height:480px) 里有一条
      `.dlg-panel .dlg-pop { bottom: 4px; max-height: 140px }`（0,2,0）。
      它会压过单类 .cmt-emoji-panel，把浮层压到输入框上。
      这里用同为 0,2,0 的选择器 + 更晚的源码顺序覆盖 bottom。 */
@media (max-height: 480px) {
    :root {
        --cmt-avatar: 32px;
        --cmt-avatar-reply: 22px;
        --cmt-row-gap: 10px;
        --cmt-pill-h: 28px;
        --cmt-emoji-tile: 32px;
        --cmt-emoji-img: 22px;
    }

    .comment-sheet,
    .immersive-comment-sheet {
        --dlg-gutter: 12px;
    }

    .cmt-editor {
        padding-top: 8px;
        padding-bottom: 8px;
    }

    .cmt-compose {
        padding: 6px 8px 4px;
    }

    .cmt-hotkey {
        display: none;
    }

    .cmt-emoji-grid {
        grid-template-columns: repeat(6, var(--cmt-emoji-tile));
    }

    .cmt-editor .cmt-emoji-panel,
    .cmt-input-wrap .cmt-mention-pop {
        bottom: calc(100% + 6px);
        /* 300px 高的键盘态里，固定 140px 会把浮层顶部顶出面板并被 overflow 裁掉；
           30vh 在 300px 时是 90px，正好落在输入框上方。 */
        max-height: min(140px, 30vh);
    }
}

/* 键盘弹起 + 空列表：head(48) + 输入区(~99) 已经占掉大半，160px 的空态会把
   输入框顶出面板。收成一行标题，保证输入区可见。 */
html.dlg-keyboard-active .cmt-empty {
    min-height: 0;
    padding: 8px var(--dlg-gutter);
    overflow: hidden;
}

html.dlg-keyboard-active .cmt-empty-icon,
html.dlg-keyboard-active .cmt-empty-sub {
    display: none;
}

/* ==========================================================================
   [hidden] 兜底：作者样式里的 display 会压掉 UA 的 [hidden]
   ==========================================================================
   必须放在所有 display 规则之后；.cmt-list 自己有 display:flex，
   空列表时要靠这条把它隐藏，空态才能 flex:1 撑满居中。 */
/* ==========================================================================
   举报子视图：覆盖评论面板内部，不新增 dialog / overlay
   ========================================================================== */
.cmt-report-view {
    position: absolute;
    inset: 0;
    bottom: var(--dlg-safe-bottom, 0px);
    z-index: 5;
    display: flex;
    flex-direction: column;
    background: var(--dlg-surface);
    overflow: hidden;
}

.cmt-report-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: var(--dlg-head-h);
    padding: var(--dlg-space-2) var(--dlg-gutter);
    box-sizing: border-box;
}

.cmt-report-title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: var(--dlg-font-title);
    font-weight: 600;
    color: var(--dlg-text);
}

.cmt-report-close {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: var(--dlg-radius-sm);
    background: transparent;
    color: var(--dlg-text-dim);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.cmt-report-form {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.cmt-report-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    padding: var(--dlg-space-2) var(--dlg-gutter);
}

.cmt-report-snippet {
    margin: 0 0 10px;
    padding: 8px 10px;
    border-radius: var(--cmt-radius);
    background: var(--cmt-surface-soft);
    color: var(--cmt-time);
    font-size: var(--dlg-font-caption);
    overflow-wrap: anywhere;
}

.cmt-report-reasons {
    border: 0;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cmt-report-legend {
    padding: 0;
    margin-bottom: 4px;
    color: var(--dlg-text);
    font-size: var(--dlg-font-label);
}

.cmt-report-reason {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: var(--cmt-hit);
    padding: 0 8px;
    border-radius: 8px;
    color: var(--dlg-text);
    font-size: var(--dlg-font-label);
    cursor: pointer;
}

.cmt-report-note-label {
    display: block;
    margin: 12px 0 6px;
    color: var(--dlg-text);
    font-size: var(--dlg-font-label);
}

.cmt-report-note {
    width: 100%;
    box-sizing: border-box;
    min-height: 72px;
    resize: vertical;
    border: 1px solid var(--dlg-border);
    border-radius: 10px;
    padding: 8px 10px;
    font-family: inherit;
    font-size: var(--dlg-font-input);
    line-height: 1.4;
    background: var(--cmt-surface-soft);
    color: var(--dlg-text);
    outline: none;
    user-select: text;
    -webkit-user-select: text;
    touch-action: auto;
}

.cmt-report-error {
    margin: 8px 0 0;
    color: var(--cmt-danger);
    font-size: var(--dlg-font-caption);
}

.cmt-report-foot {
    flex: 0 0 auto;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: var(--dlg-space-3) var(--dlg-gutter);
}

.cmt-report-btn {
    min-height: var(--cmt-hit);
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    background: var(--cmt-surface-pill);
    color: var(--dlg-text);
    font-size: var(--dlg-font-label);
    cursor: pointer;
}

.cmt-report-btn--primary {
    background: var(--cmt-brand);
    color: var(--dlg-on-brand);
    font-weight: 600;
}

@media (hover: hover) {
    .cmt-report-close:hover,
    .cmt-report-btn:hover {
        color: var(--dlg-text);
    }

    .cmt-report-reason:hover {
        background: var(--dlg-hover);
    }
}

.cmt-list[hidden],
.cmt-empty[hidden],
.cmt-error[hidden],
.cmt-fold[hidden],
.cmt-more-row[hidden],
.cmt-edit[hidden],
.cmt-edit-error[hidden],
.cmt-mention-pop[hidden],
.cmt-emoji-panel[hidden],
.cmt-emoji-recent[hidden],
.cmt-reply-hint[hidden],
.cmt-load-more[hidden],
.cmt-edited[hidden],
.cmt-submit[hidden],
.cmt-input-wrap[hidden],
.cmt-vote-count[hidden],
.cmt-report-view[hidden],
.cmt-report-error[hidden] {
    display: none !important;
}

/* ==========================================================================
   减少动效
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .cmt-delete-confirm,
    .cmt-skeleton-line,
    .cmt-action,
    .cmt-vote,
    .cmt-fold,
    .cmt-more-item,
    .cmt-emoji-item,
    .cmt-emoji-btn,
    .cmt-submit {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }

    .cmt-action:active,
    .cmt-vote:active,
    .cmt-fold:active,
    .cmt-more-item:active,
    .cmt-emoji-item:active,
    .cmt-emoji-btn:active,
    .cmt-submit:active:not(:disabled) {
        transform: none;
    }
}
