/* style.css */

/* --- 1. 定义颜色变量 --- */
:root {
    --column-gap: 0.6rem;

    /* --- 白天模式 (Light Mode) 默认值 --- */
    --bg-body: #f4f7f6;           /* 主背景色 (body) */
    --bg-card: #ffffff;           /* 头部、卡片、控制栏背景 */
    --bg-input: #fdfdfd;          /* 输入框背景 */
    --bg-status: #eee;            /* 状态栏背景 */
    --bg-tag: #e9ecef;            /* Tag标签背景 / 清空按钮背景 */
    --bg-tag-hover: #d1d9e0;      /* Tag标签悬停背景 */

    --text-main: #333;            /* 主文本色 */
    --text-sub: #555;             /* 次要文本色 (状态栏、清空按钮) */
    --text-label: #4a4a4a;        /* Label文字 */
    --text-header: #2c3e50;       /* 标题颜色 (H1, H3) */
    --text-artist: #d9534f;       /* Artist/角色颜色 */

    --accent-color: #007bff;      /* 按钮、高亮色 */
    --accent-hover: #0056b3;

    --border-color: #ddd;         /* 头部/设置页面的边框 */
    --border-input: #ccc;         /* 输入框边框 */
    --border-card: #e0e0e0;       /* 卡片边框 */

    --shadow-header: rgba(0,0,0,0.05);
    --shadow-card: rgba(0,0,0,0.08);
    --shadow-hover: rgba(0,0,0,0.1);
}

/* --- 2. 黑夜模式 (Dark Mode) 覆盖 --- */
body.dark-mode {
    --bg-body: #121212;           /* 深灰近黑 */
    --bg-card: #1e1e1e;           /* 稍亮的卡片背景 */
    --bg-input: #2d2d2d;          /* 输入框深色 */
    --bg-status: #333;
    --bg-tag: #3a3a3a;
    --bg-tag-hover: #4a4a4a;

    --text-main: #e0e0e0;         /* 亮灰白 */
    --text-sub: #aaaaaa;
    --text-label: #cccccc;
    --text-header: #ffffff;
    --text-artist: #ff7f7f;

    --accent-color: #3a8fdc;
    --accent-hover: #2c7bb6;

    --border-color: #333;
    --border-input: #555;
    --border-card: #333;

    --shadow-header: rgba(0,0,0,0.5);
    --shadow-card: rgba(0,0,0,0.5);
    --shadow-hover: rgba(0,0,0,0.7);
}

/* --- [新增] 预览弹窗样式 --- */
#preview-modal .preview-modal-content {
    background: transparent;
    width: 90%;
    height: 85vh;
    border-radius: 12px;
    overflow: visible;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* 核心：外层容器允许内容溢出，内层图片绝对定位 */
.preview-image-outer {
    flex: 1;
    position: relative;
    overflow: visible;
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
    z-index: 10;
}

#preview-image {
    position: absolute;
    max-width: none; /* 解除限制 */
    max-height: none; /* 解除限制 */
    transform-origin: center center;
    cursor: grab;
    will-change: transform;
    /* 初始大小设为 contain 逻辑通过 JS 控制 */
    object-fit: contain;
}

.preview-tags-container {
    padding: 12px;
    background: transparent;
    overflow-y: auto;
    max-height: 30%; /* 限制 Tag 区域高度 */
    z-index: 1;
}

#preview-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* 悬浮时增加亮度而非变暗 */
.preview-tag:hover {
    filter: brightness(1.2);
    background: rgba(255, 255, 255, 0.2);
}

.preview-tag {
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.9rem;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1); /* 白色半透明背景 */
    backdrop-filter: blur(4px);           /* 标签自带微弱模糊 */
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    transition: all 0.2s;
    user-select: none;
}


/* Tag 颜色分类 */
.preview-tag.tag-artist {
    background-color: rgba(217, 83, 79, 0.1);
    color: var(--text-artist); /* 红色系 */
    border: 1px solid rgba(217, 83, 79, 0.3);
}

.preview-tag.tag-character {
    background-color: rgba(0, 170, 0, 0.1);
    color: #00aa00; /* 绿色系 */
    border: 1px solid rgba(0, 170, 0, 0.3);
}

.preview-tag.tag-general {
    /* 默认样式 */
    border: 1px solid transparent;
}

/* Dark Mode 适配 */
body.dark-mode .preview-tag.tag-artist {
    color: #ff7f7f;
    background-color: rgba(255, 127, 127, 0.15);
    border-color: rgba(255, 127, 127, 0.3);
}

body.dark-mode .preview-tag.tag-character {
    color: #4caf50;
    background-color: rgba(76, 175, 80, 0.15);
    border-color: rgba(76, 175, 80, 0.3);
}

/* 确保移动端长按不弹出系统菜单 */
.img-container, .image-download-link, .image-download-link {
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
    -webkit-user-drag: none !important;
}

/* --- 基本样式 --- */
/*noinspection CssUnresolvedCustomProperty*/
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    /* 使用变量 */
    background-color: var(--bg-body);
    color: var(--text-main);
}

/* --- 修改 Header：确保它支持半透明并有过渡 --- */
#main-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    /* 使用 rgba 替代变量以实现透明 */
    background-color: rgba(255, 255, 255, 0.75) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 50; /* 基础层级 */
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.3s ease-in-out;
}

/* 标题居中修正 */
#main-header h1 {
    position: absolute;
    right: 45%;
    transform: translateX(-50%);
    margin: 0;
    z-index: -1; /* 确保不遮挡左右按钮点击 */
}
/* --- 分页栏样式 (复用 Tag 栏风格) --- */
.page-manager {
    display: flex;
    flex-direction: column;
    position: relative;    /* 开启定位，使 z-index 生效 */
    z-index: 100;         /* 确保层级高于 header 的其他内容 */
    align-items: flex-end; /* 右对齐 */
    gap: 4px;
    margin-left: 15px;
}

.page-estimate-text {
    font-size: 1rem;
    color: var(--text-sub);
    font-weight: bold;
    margin-right: 4vw;
}

.page-container {
    display: flex;
    align-items: center;
    background: var(--bg-tag);
    border-radius: 4px;
    padding: 4px 12px;
    margin-right: 3vw;
    border: 2px solid var(--border-color);
    transition: background 0.6s;
}

.page-container:hover {
    background: var(--bg-tag-hover);
}

.page-label {
    font-size: 0.85rem;
    color: var(--text-label);
    margin-right: 8px;
    white-space: nowrap;
}

.page-input {
    width: 60px;
    border: none;
    background: transparent;
    color: var(--text-main);
    font-size: 0.9rem;
    font-weight: bold;
    text-align: center;
    outline: none;
}

/* 移除 Chrome/Safari/Edge 的输入框箭头 */
.page-input::-webkit-outer-spin-button,
.page-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* 兼容火狐 */
.page-input[type=number] {
    -moz-appearance: textfield;
}
/* 跳转按钮样式 */
.page-jump-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    padding: 2px 4px;
    margin-left: 4px;
    cursor: pointer;
    color: var(--text-sub);
    border-radius: 4px;
    transition: all 0.2s;
}

.page-jump-btn:hover {
    background: var(--bg-tag-hover);
    color: var(--accent-color);
}

.page-jump-btn svg {
    width: 16px;
    height: 16px;
}
/* --- 修改 Status Bar：核心悬浮与联动逻辑 --- */
#status-bar {
    position: fixed;
    /* 初始位置：位于 Header 下方一点点，避免遮挡左侧的设置按钮 */
    top: 93px;
    right: 15px; /* 左侧对齐 */

    /* --- 胶囊形态核心设置 --- */
    width: auto;               /* 宽度随文字自动伸缩 */
    max-width: 60%;            /* 限制最大宽度，防止太长 */
    height: 34px;              /* 胶囊高度 */
    line-height: 34px;         /* 文字垂直居中 */
    padding: 0 20px;           /* 胶囊两侧留白 */
    border-radius: 30px;       /* 圆角极值，形成胶囊形 */

    /* --- 视觉效果：默认/成功状态 (绿色系半透明) --- */
    background-color: transparent !important; /* 默认浅绿背景 */
    color: rgba(40, 167, 69, 0.58);                                      /* 默认深绿文字 */
    border: 1px solid rgba(40, 167, 69, 0.2);            /* 细微描边 */
    backdrop-filter: none !important;              /* 去除毛玻璃模糊 */
    -webkit-backdrop-filter: none !important;
    /* 动画与层级 */
    z-index: 2002; /* 必须高于 Header (2000) */
    font-size: 0.85rem;
    font-weight: 600; /* 字体加粗一点更清晰 */
    text-align: center;
    white-space: nowrap;      /* 文字不换行 */
    overflow: hidden;         /* 超出省略 */
    text-overflow: ellipsis;
    pointer-events: none;     /* 让点击穿透，不影响下方操作 */

    /* 状态切换时的平滑过渡 */
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    opacity: 1;
    visibility: visible;
}

/* 自动隐藏类 */
.status-bar-hidden {
    opacity: 0 !important;
    visibility: hidden !important;
    transform: translateY(-10px) scale(0.8); /* 向上微移并缩小消失 */
}
/* --------------------------------------------------------------------------
   颜色状态变体 (根据 JS 的 setStatus 类型)
   -------------------------------------------------------------------------- */

/* 1. 加载中 / 警告 (Loading / Warning) -> 黄色 */
#status-bar.loading {
    background-color: transparent !important;
    color: rgba(224, 168, 0, 0.89) !important; /* 深黄色文字，保证可读性 */
    border-color: rgba(255, 193, 7, 0.3) !important;
}
/* 加载时让它稍微跳动一下，增加动态感 */
#status-bar.loading::before {
    content: "● "; /* 前缀加个点 */
    animation: blink 1s infinite;
}

/* 2. 错误 (Error) -> 红色 */
#status-bar.error {
    background-color: transparent !important;
    color: rgba(220, 53, 69, 0.89) !important;
    border-color: rgba(220, 53, 69, 0.3) !important;
}

/* 3. 成功 (Success) -> 绿色 (保持默认，也可强制指定) */
#status-bar.success {
    background-color: transparent !important;
    color: rgba(40, 167, 69, 0.89) !important;
    border-color: rgba(40, 167, 69, 0.3) !important;
}

/* --- 联动逻辑：利用 CSS 相邻选择器 --- */

/* 当 JS 给 Header 加上隐藏类时 */
#main-header.header-hidden {
    transform: translateY(-100%);
}

/* 状态栏探测到前一个兄弟节点(Header)被隐藏，立即上移到顶端 */
#main-header.header-hidden + #status-bar {
    top: 0;
    background-color: rgba(255, 255, 255, 0) !important; /* 顶置时略微加深背景 */
}

/* --- 深色模式适配 --- */
body.dark-mode #main-header {
    background-color: rgba(30, 30, 30, 0.75) !important;
}

body.dark-mode #status-bar {
    background-color: transparent !important;
    color: #ccc;
}

body.dark-mode #main-header.header-hidden {
    background-color: rgba(30, 30, 30, 0.9) !important;
}

header {
    /* 使用变量 */
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 4px var(--shadow-header);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
    /* 使用变量 */
    color: var(--text-header);
}

main {
    padding-top: 100px !important;
    max-width: 1800px;
    margin: 1.5rem auto;
    padding: 0 0.5rem;
}

/* --- 控制区域 --- */
.controls-container {
    /* 使用变量 */
    background-color: var(--bg-card);
    box-shadow: 0 2px 5px var(--shadow-card);
    padding: 0.5rem;
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap; /* 移动端换行 */
    gap: 1rem 1.5rem;
    align-items: flex-end; /* 按钮和输入框底端对齐 */
    margin-bottom: 1rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex-grow: 1; /* 移动端占满 */
}

.control-group.control-group-wide {
    min-width: 300px;
    flex-grow: 3; /* 搜索框占比更大 */
}

.control-group label {
    font-weight: 600;
    font-size: 0.85rem;
    /* 使用变量 */
    color: var(--text-label);
}

.control-group input[type="text"],
.control-group input[type="number"],
.control-group select {
    padding: 0.6rem;
    /* 使用变量 */
    border: 1px solid var(--border-input);
    background-color: var(--bg-input);
    color: var(--text-main); /* 确保输入框内的文本颜色正确切换 */
    border-radius: 5px;
    font-size: 0.95rem;
}

.control-group input[type="text"]:focus,
.control-group input[type="number"]:focus,
.control-group select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(0,123,255,0.2); /* 蓝色阴影不变 */
}

button {
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    /* 使用变量 */
    background-color: var(--accent-color);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    height: 38px; /* 与输入框等高 */
}

button:hover {
    background-color: var(--accent-hover);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

button:active {
    background-color: var(--accent-hover); /* 保持一致性 */
}

button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* --- 常用 Tags --- */
.common-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 0.5rem;
}

.common-tags-container label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    /* 使用变量 */
    background-color: var(--bg-tag);
    color: var(--text-main);
    padding: 0.4rem 0.8rem;
    border-radius: 15px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.2s;
    user-select: none;
}
.common-tags-container label:hover {
    background-color: var(--bg-tag-hover);
}

.common-tags-container input[type="checkbox"] {
    margin-right: 0.2rem;
}

/* --- 帖子网格 (瀑布流) --- */
.post-grid-container {
    width: 100%;
}

/* 关键修改: 使用 Flexbox 布局和 CSS 变量实现动态列数 */
#post-grid {
    display: flex;
    flex-wrap: nowrap; /* 确保列不换行 */
    gap: var(--column-gap);
    margin-bottom: 2rem;
    align-items: flex-start; /* 瀑布流的关键 */
    min-height: 50vh; /* 保证初始可见，便于计算高度 */
}

#post-grid .column {
    /* JS 将通过设置 --column-width 变量来控制每一列的宽度 */
    flex-shrink: 0;
    flex-grow: 1;
    width: var(--column-width, 19%); /* 默认值 19% 接近 5 列 */
    display: flex;
    flex-direction: column;
    gap: var(--column-gap);
    transition: width 0.3s ease;
}
/* --- 单列模式 (1 列) 样式 --- */

/* 1. 单列模式下的网格容器 (#post-grid) 样式 */
#post-grid.single-column-grid {
    display: block; /* 覆盖多列网格的 flex/grid/columns 样式 */
    width: 100%;
    /* 清除多列模式可能留下的样式 */
    column-count: initial;
    column-gap: initial;
    max-width: 100%;
    margin: 0 auto;
    padding: 0; /* <--- 修复点：移除左右 padding，让内部的 wrapper 负责居中 */
}
/* 修复：单列模式 column 宽度异常 */
.single-column-grid .column {
    width: 100% !important;
}

/* 2. 单列模式下包含帖子的列容器 (.single-column-wrapper) 样式 */
.single-column-wrapper {
    /* 确保在单列模式下，这唯一的列容器占满 #post-grid 的宽度 */
    width: 100%;
    margin: 0 auto; /* 居中对齐 */
}
.post-item {
    /* 使用变量 */
    background-color: var(--bg-card);
    border: 1px solid var(--border-card);
    box-shadow: 0 2px 4px rgba(0,0,0,0.06);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;

    /* 确保 post-item 之间有间距 */
    margin-bottom: var(--column-gap);
    width: 100%; /* 占满 column 容器的宽度 */
}

.post-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 12px var(--shadow-hover);
}

.image-download-link {
    display: block;
    text-decoration: none;
    cursor: pointer;
}

.post-item .img-container {
    position: relative;
    width: 100%;
    /* 核心：通过 JS 注入 aspect-ratio 来防止抖动 */
    aspect-ratio: 1 / 1; /* 默认值 */
    background-color: var(--bg-status); /* 使用浅色背景 */
    overflow: hidden; /* 确保圆角生效 */
}

.post-item img:not(.source-icon) {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover; /* 填充容器 */
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 0; /* 默认为0，加载后变为1 */
}
.post-item:hover img {
    transform: scale(1.03);
}

.post-item img.loaded {
    opacity: 1;
}

.post-item .info {
    padding: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
    /* 使用变量 */
    background-color: var(--bg-card);
    color: var(--text-main);
}

.post-item .tags {
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--text-sub);
    /* 限制高度并显示省略号 */
    max-height: 4.2em; /* 约 3 行 */
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-all;
}

.post-item .artist {
    font-size: 0.85rem;
    font-weight: 600;
    /* 使用变量 */
    color: var(--text-artist);
    /* 强制不换行 */
    white-space: nowrap;
    overflow: hidden;
    cursor: pointer;
}
/* 可选：添加一个悬停效果（如下划线），让交互感更强 */
.info .chara:hover {
    text-decoration: underline;
}

.post-item .actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto; /* 推动到底部 */
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-card); /* 使用卡片边框变量 */
}

.post-item .details-link {
    font-size: 0.8rem;
    color: var(--text-sub);
    text-decoration: none;
}
.post-item .details-link:hover {
    text-decoration: underline;
}
.post-item .dimensions {
    font-size: 0.8rem;
    color: var(--text-sub);
    font-weight: 500;
}
/* 调整底部操作栏，让右侧的元素（尺寸+按钮）成组 */
.post-item .actions {
    /* 保持原有的 space-between，左边是来源，右边是尺寸+按钮 */
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75em;
    color: var(--text-sub);
    margin-top: 2px;
}

/* 新增：右侧尺寸和按钮的容器 */
.action-right-group {
    display: flex;
    align-items: center;
    gap: 8px; /* 尺寸文字和图标之间的间距 */
}

/* 转发/复制按钮样式 */
.forward-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-sub);
    transition: all 0.2s ease;
    padding: 2px;
    border-radius: 4px;
}

.forward-btn:hover {
    color: var(--accent-color); /* 悬停变色 */
    background-color: var(--bg-tag); /* 悬停背景 */
    transform: translateY(-1px);
}

.forward-btn:active {
    transform: scale(0.95);
}

/* 按钮点击后的动画类 (JS控制) */
.forward-btn.copied {
    color: #28a745 !important; /* 绿色 */
}

/* --- 加载更多 --- */
.loading-trigger {
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.spinner {
    border: 4px solid var(--bg-status); /* 使用浅色背景 */
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


/* --- 响应式调整 (非网格布局相关) --- */
/* 768px 及以下: 适用于移动端控件布局 */
/* --- 响应式调整 (非网格布局相关) --- */
/* 768px 及以下: 适用于移动端控件布局 */
/* --- 找到 @media (max-width: 768px) 内部的相关部分并替换 --- */

@media (max-width: 768px) {
    /* 1. 核心修复：移除 header 的裁剪，并调整高度以适应内容 */
    #main-header {
        overflow: visible;      /* 必须允许内容溢出，防止分页栏阴影或边框被切断 */
        height: auto;           /* 允许高度自适应内部布局 */
        min-height: 60px;
        padding: 5px 10px;      /* 增加内边距 */
    }

    /* 2. 优化 Page Manager 布局：确保其在窄屏下不被裁切且易于操作 */
    .page-manager {
        display: flex;
        flex-direction: row;    /* 保持横向排列 */
        align-items: center;
        gap: 4px;
        margin-left: 5px;       /* 减小左边距，腾出更多空间 */
        flex-shrink: 1;         /* 允许被压缩 */
        min-width: 0;           /* 允许收缩 */
        max-width: none;        /* 移除最大宽度限制，由 Flex 容器自行分配空间 */
        z-index: 101;           /* 确保在最上层 */
    }

    /* 4. 优化输入框容器：防止点击困难 */
    .page-container {
        padding: 4px 6px;       /* 进一步紧凑内边距 */
        margin-right: 0;        /* 移除右边距 */
        flex-shrink: 0;         /* 保证输入区域不被压缩到看不见 */
        border-width: 1px;      /* 窄屏下细边框更精致 */
    }

    /* 5. 增大输入框点击区域 */
    .page-input {
        width: 35px;            /* 减小宽度以适应窄屏 */
        font-size: 1rem;        /* 增加字体大小，防止 iOS 缩放并提高可读性 */
    }

    /* 6. 调整 Header 左右结构：确保 AI 按钮和分页栏能并排 */
    .header-left {
        width: auto;
        flex-grow: 1;
        justify-content: flex-start;
        gap: 5px;
    }
        .page-estimate-text {
        font-size: 0.9rem;
        color: var(--text-sub);
        font-weight: bold;

        /* 省略逻辑 */
        flex-shrink: 1;
        min-width: 0;
        max-width: 140px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    header {
        flex-direction: column;
        gap: 0.8rem;
        padding: 0.8rem 1rem;
    }
    #main-header h1 {
        display: none;
    }



    .header-left {
        width: 100%;
        justify-content: space-between; /* 移动端让图标分散对齐 */
    }

    .controls-container {
        flex-direction: column;
        align-items: stretch; /* 关键：让子元素拉伸填满容器 */
        gap: 1rem;
        padding: 1rem;
    }

    /* 强制重置所有控件组的宽度限制 */
    .control-group,
    .control-group.control-group-wide {
        flex-grow: 1;
        width: 100%;             /* 占满一行 */
        min-width: 0 !important; /* 【核心】使用 !important 覆盖 HTML 中的 style="min-width:..." */
        margin: 0;
    }

    /* 强制输入框、下拉框、按钮占满父容器宽度 */
    .control-group input[type="text"],
    .control-group input[type="number"],
    .control-group select,
    .control-group button:not(#clear-tags-btn){
        width: 100% !important;  /* 【核心】覆盖 HTML 中的 style="width: 80px" 等内联样式 */
        max-width: 100%;
        box-sizing: border-box;  /* 防止 padding 导致超出容器 */
        height: 44px;            /* 增大高度，方便手指点击 */
    }

    /* 调整 Tags 输入框容器高度以匹配新的输入框高度 */
    .tags-input-container {
        height: 44px !important; /* 确保移动端高度为 44px */
    }

    /* 针对只有空格的 label (用于按钮占位)，在手机上可以隐藏或减小边距以节省空间 */
    .control-group label {
        font-size: 0.9rem;
        margin-bottom: 0.3rem;
    }
}

/* 1. 相对定位容器 */
.tags-input-container {
    position: relative;
    /* 继承 control-group 的高度控制 */
    height: 38px;
}

/* 2. 调整输入框，为按钮留出空间 */
#tags-input {
    /* height: 50%; <-- 移除旧的 50% 限制 */
    height: 100%; /* 新增：填充父容器高度 */
    width: 100%;
    /* 覆盖 button 的高度和输入框对齐 */
    padding: 0.6rem;
    box-sizing: border-box; /* 确保 padding 不会撑大高度 */

    /* 确保输入框在被绝对定位按钮遮挡时能显示边框 */
    border: 1px solid var(--border-input);
}

.tag-suggestions {
    position: absolute; /* 确保它是悬浮的 */
    background-color: var(--bg-card); /* 或者直接写 #ffffff */
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15); /* 增加阴影增加层级感 */
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    width: 100%; /* 宽度跟随输入框 */
}
/* --- 联想框项整体布局 --- */
.suggestion-item {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    justify-content: space-between; /* 核心：让左右两大块分别靠左和靠右，多余空间全在中间 */
    align-items: center;
    border-bottom: 1px solid var(--bg-status);
}

.suggestion-item:hover {
    background: var(--bg-tag-hover);
}

/* --- 左侧：名字容器 --- */
.suggestion-item .tag-names {
    display: flex;
    flex-direction: column;    /* 核心：上下两行排列 */
    align-items: flex-start;   /* 左对齐 */
    flex-grow: 1;              /* 占据左侧盈余空间 */
    min-width: 0;              /* 防止超长文本撑破容器 */
    margin-right: 15px;        /* 保证与右侧元素之间最少有间距 */
}

.suggestion-item .en-name {
    color: inherit;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;   /* 超长省略号 */
    max-width: 100%;
}

.suggestion-item .cn-name {
    color: var(--text-sub);
    font-size: 0.85em;
    margin-left: 0;            /* 移除之前 JS 里旧样式的 margin-left */
    margin-top: 2px;           /* 英文与中文的上下间距 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* --- 右侧：数据与按钮容器 --- */
.suggestion-item .tag-meta {
    display: flex;
    align-items: center;
    gap: 12px;                 /* 核心：数量和纠错按钮的固定间距 */
    flex-shrink: 0;            /* 防止右侧区域被挤压 */
}

.suggestion-item .post-count {
    color: #888;
    font-size: 1.2em;
    font-family: monospace;    /* 数字使用等宽字体更整齐 */
}

/*纠错按钮 --- */
.suggestion-item .feedback-btn {
    /* 1. 缩小内边距：上下 1px，左右 5px */
    padding: 1px 6px;
    /* 2. 强制缩小字号 */
    font-size: 11px;
    /* 3. 限制高度，防止被 flex 撑大 */
    line-height: 1.2;
    height: 18px;
    /* 4. 移除可能的最小宽度限制 */
    min-width: unset;

    /* 5. 视觉优化 */
    color: var(--text-sub);
    background-color: transparent; /* 背景透明更显小 */
    border: 1px solid var(--border-color);
    border-radius: 3px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.suggestion-item .feedback-btn:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
    background-color: rgba(0, 123, 255, 0.05); /* 淡淡的高亮 */
}

.suggestion-item.tag-cat-0 .en-name { color: #0073ff; } /* General */
.suggestion-item.tag-cat-1 .en-name { color: #c00000; } /* Artist */
.suggestion-item.tag-cat-3 .en-name { color: #a000a0; } /* Copyright */
.suggestion-item.tag-cat-4 .en-name { color: #00aa00; } /* Character */

/* --- 纠错弹窗样式 (置顶居中，带毛玻璃效果) --- */
#issue-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45); /* 稍微深一点的遮罩 */
    backdrop-filter: blur(5px);      /* 增强模糊效果，与预览弹窗保持一致 */
    -webkit-backdrop-filter: blur(5px);
    display: none; 
    align-items: center;
    justify-content: center;
    z-index: 9999; 
}

#issue-modal.show {
    display: flex !important;
}

.issue-modal-content {
    width: 90%;
    max-width: 450px;
    background: rgba(255, 255, 255, 0.9); /* 白天模式半透明 */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--text-main, #333);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    padding: 24px;
    animation: modalFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.issue-modal-content h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--text-header);
    font-size: 1.25rem;
    text-align: center;
}

/* 适配深色模式 */
body.dark-mode .issue-modal-content {
    background: rgba(30, 30, 30, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.issue-form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
}

.issue-form-group label {
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-label, #555);
    display: flex;
    align-items: center;
    gap: 4px;
}

.issue-form-group input,
.issue-form-group textarea {
    padding: 12px;
    border: 1px solid var(--border-input, #ccc);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05); /* 微弱透明背景 */
    color: var(--text-main, #333);
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.issue-form-group input:focus,
.issue-form-group textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

.issue-form-group input[readonly] {
    background-color: var(--bg-status, #eee);
    opacity: 0.7;
    cursor: not-allowed;
}

.issue-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}

.issue-modal-actions button {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s;
}

#issue-cancel-btn {
    background: transparent;
    color: var(--text-sub);
    border: 1px solid var(--border-color);
}

#issue-cancel-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-main);
}

body.dark-mode #issue-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}
.suggestion-item.tag-cat-5 .en-name { color: #ff8a00; } /* Meta/Style */

/* 3. 绝对定位清空按钮 */
#clear-tags-btn {
    position: absolute;
    right: 8px;       /* 靠右 */
    top: 50%;
    transform: translateY(-50%);

    width: 20px;      /* 固定大小 */
    height: 20px;
    min-width: 20px;  /* 强制不让浏览器放大 */
    min-height: 20px;

    padding: 0;
    margin: 0;

    display: flex;
    justify-content: center;
    align-items: center;

    border: none;
    border-radius: 50%;
    /* 使用变量 */
    background: var(--bg-tag);
    cursor: pointer;

    font-size: 16px;
    line-height: 1;
    color: var(--text-sub);

    z-index: 10; /* 避免被 input 覆盖 */
}


#clear-tags-btn:hover {
    color: var(--text-main);
    background-color: var(--bg-tag-hover);
}

#clear-tags-btn:disabled {
    display: none; /* 清空时隐藏 */
}
/* --- 头部图标区域 --- */
.header-left {
    display: flex;
    align-items: center;
    gap: 10px; /* 两个图标之间的间距 */
    flex-shrink: 0; /* 防止整个右侧容器被挤压 */
    margin-right: 23px; /* 给左侧留点缓冲 */
}

.header-icon {
    /* 使用变量 */
    color: var(--text-sub);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0; /* [关键] 防止图标在空间不足时被挤压变形或挤出屏幕 */
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
    cursor: pointer;
    text-decoration: none; /* 防止 a 标签下划线 */
}

.header-icon:hover {
    background-color: var(--bg-tag);
    color: var(--accent-color);
}
/* 帮助弹窗样式 */
.help-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}
.help-modal.show { display: flex; }
.help-modal-content {
    width: 50vw;
    max-width: 900px;
    background: rgba(255,255,255,0.85);
    color: var(--text-main);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    overflow: hidden;
}
body.dark-mode .help-modal-content {
    background: rgba(30,30,30,0.85);
    border-color: #444;
}
.help-modal-header {
    padding: 12px 16px;
    font-weight: 600;
    border-bottom: 1px solid var(--border-card);
}
.help-list {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.help-item {
    padding: 12px;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.help-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px var(--shadow-hover);
    background: var(--bg-tag);
}
.help-item-title {
    font-size: 0.95rem;
    font-weight: 600;
}
.help-item-desc {
    font-size: 0.85rem;
    color: var(--text-sub);
    margin-top: 4px;
}
/* --- [新增] 设置页面样式 --- */
.settings-container {
    background-color: var(--bg-card);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 5px var(--shadow-card);
    max-width: 800px;
    margin: 0 auto;
    color: var(--text-main);
}

.settings-group {
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
}
.settings-group:last-child {
    border-bottom: none;
}

.settings-group h3 {
    margin-top: 0;
    color: var(--text-header);
    margin-bottom: 1rem;
}

.hint {
    display: block;
    font-size: 0.85rem;
    color: var(--text-sub);
    margin-top: 0.3rem;
}

textarea#tags-list-input {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--border-input);
    border-radius: 5px;
    font-family: monospace;
    font-size: 0.95rem;
    resize: vertical;
    box-sizing: border-box; /* 防止padding撑大宽度 */
    background-color: var(--bg-input);
    color: var(--text-main);
}

.actions-row {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.cancel-btn {
    text-decoration: none;
    color: var(--text-sub);
    font-size: 0.95rem;
}
.cancel-btn:hover {
    text-decoration: underline;
}
.fav-btn {
    cursor: pointer;
    font-size: 3em;
    line-height: 1;
    color: #ccc; /* 默认灰色 */
    margin-left: 10px;
    transition: color 0.2s;
    user-select: none;
}
.fav-btn:hover {
    color: #ff9999;
}
.fav-btn.active {
    color: #ff4444; /* 激活红色 */
}
.fav-btn.loading {
    opacity: 0.5;
    cursor: wait;
}

/* --- 角色行布局 (Flexbox) --- */
.chara-row {
    display: flex;
    justify-content: space-between; /* 关键：两端对齐 */
    align-items: center;            /* 垂直居中对齐 */
    gap: 8px;                       /* 文本和按钮之间的最小间距 */
    width: 100%;                    /* 占满父容器宽度 */
    margin: 4px 0;                  /* 上下间距 */
}

/* --- 角色名文本 --- */
.chara-name {
    font-weight: bold;
    font-size: 0.95em;
    color: var(--text-main);           /* 深色文字 (根据你的背景调整，如果背景是深色则用 #eee) */

    /* 文本过长省略处理 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;          /* 占据剩余空间 */
    min-width: 0;          /* 防止 Flex 子元素溢出 */
}

/* --- 收藏按钮区域 (容器) --- */
.fav-section {
    flex-shrink: 0;       /* 按钮不可压缩 */
    display: flex;
    flex-direction: column;  /* 垂直排列 */
    align-items: center;
    justify-content: center;
    gap: 2px;             /* 图标和分数之间的间距 */
}

/* --- 收藏按钮 (爱心) --- */
.fav-btn {
    cursor: pointer;
    font-size: 3em;     /* 调整大小，不要太大撑开高度 */
    line-height: 1;
    color: #ccc;          /* 默认灰色 */
    transition: color 0.2s, transform 0.2s;
    user-select: none;
    margin-right: 2px;    /* 稍微离右边框一点距离 */
}

.fav-btn:hover {
    color: #ff9999;
    transform: scale(1.15);
}

.fav-btn.active {
    color: #ff4444;       /* 激活红色 */
}

.fav-btn.loading {
    opacity: 0.5;
    cursor: wait;
}
/* style.css */

/* --- 信息栏整体布局 --- */
.post-item .info {
    padding: 10px;
    background-color: var(--bg-card);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    gap: 6px; /* 上下部分的间距 */
}

/* --- 头部区域 (Flexbox) --- */
.info-header {
    display: flex;
    justify-content: space-between; /* 左右两端对齐 */
    align-items: center;            /* 垂直居中 (核心：让爱心在两行文字中间) */
    width: 100%;
    gap: 8px;                       /* 文字和爱心之间的间距 */
}

/* --- 左侧文字列 --- */
.meta-text {
    display: flex;
    flex-direction: column; /* 垂直排列 Artist 和 Chara */
    justify-content: center;
    flex-grow: 1;           /* 占据剩余空间 */
    min-width: 0;           /* 关键：防止 Flex 子元素溢出 */
    gap: 2px;               /* 两行文字的间距 */
}

/* --- 文字样式重置 --- */

.artist {
    font-size: 0.85em;
    color: var(--text-sub);
    cursor: pointer; /*  显示手型光标 */
    transition: color 0.2s;
}

.artist:hover {
    color: var(--accent-color); /*  悬停变色 (类似链接色) */
    text-decoration: underline; /*  下划线提示 */
}
.chara {
    font-weight: bold;
    font-size: 0.95em;
    color: var(--text-main);
}
/* 单个角色标签样式与悬停下划线（只作用于被悬停的标签） */
.chara .chara-tag {
    cursor: pointer;
    text-decoration: none;
    margin-right: 4px;
}
/* 避免整行下划线，仅在单个标签悬停时显示 */
.info .chara:hover {
    text-decoration: none;
}
.chara .chara-tag:hover {
    text-decoration: underline;
    color: var(--accent-color);
}

/* --- 右侧收藏按钮区域 --- */
.fav-section {
    flex-shrink: 0; /* 按钮不可压缩 */
    display: flex;
    flex-direction: column;  /* 垂直排列 */
    align-items: center;
    justify-content: center;
    padding-left: 4px; /* 稍微增加左侧间距 */
    gap: 2px;             /* 图标和分数之间的间距 */
}

.fav-btn {
    cursor: pointer;
    font-size: 3em;
    line-height: 1;
    color: #ccc;
    transition: color 0.2s, transform 0.2s;
    user-select: none;
}

.fav-btn:hover {
    color: #ff9999;
    transform: scale(1.15);
}

.fav-btn.active {
    color: #ff4444;
}

.fav-btn.loading {
    opacity: 0.5;
    cursor: wait;
}

/* --- 分数显示 --- */
.score-display {
    font-size: 0.9em;
    color: var(--text-sub);
    margin-left: 4px;
    font-weight: 500;
    min-width: 20px;
    text-align: center;
}

/* --- 底部 Actions 保持不变 --- */
.actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75em;
    color: var(--text-sub);
    margin-top: 2px;
}

/* --- 新增：媒体预览容器和播放图标样式 (用于视频和 GIF 特殊处理) --- */

/* 预览图容器：用于定位内部的图标或标签 */
.preview-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.preview-container img {
    /* 禁用 iOS 系统的长按弹出菜单 (核心) */
    -webkit-touch-callout: none;

    /* 禁用安卓及主流浏览器的文本选择，防止长按选中文字 */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;

    /* 某些浏览器下禁止系统默认行为 */
    -webkit-tap-highlight-color: transparent;
}
/* 视频预览容器：可用于添加额外视觉标记 */
.video-preview {
    /* 视频预览可以添加一个微弱的阴影或边框来区分，可选 */
}

/* GIF 标签叠加层 */
.gif-tag-overlay {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background-color: rgba(0, 0, 0, 0.6); /* 深色背景 */
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    border-radius: 3px;
    z-index: 5; /* 确保在图片上方 */
    pointer-events: none; /* 允许点击穿透 */
    letter-spacing: 0.5px;
}
/* pixivpool图标 */
/* 确保父容器是定位参考点 */
.post-item .img-container {
    position: relative; /* 必须确保这一行存在 */
    overflow: hidden;
}

/* 统一的顶部右上角标签样式 */
.pixiv-top-tag {
    position: absolute; /* 关键：使其脱离文档流悬浮 */
    top: 1rem;
    right: 1rem;
    display: flex;
    align-items: center;
    padding: 2px 6px;
    background-color: rgba(0, 0, 0, 0.4); /* 半透明黑 */
    color: #fff;
    border-radius: 4px;
    z-index: 5;
    pointer-events: none; /* 防止遮挡点击 */
}

.pixiv-top-tag svg {
    /* 使用 em，1em 等于当前父元素的 font-size */
    width: 0.9em;
    height: 1em;
    fill: currentColor;
    flex-shrink: 0;
}

.pixiv-top-tag span {
    font-size: 1em; /* 继承父级缩放 */
    font-weight: bold;
    line-height: 1;
    margin-left: 0.3em;
}
/* pixivpool图标结束 */
/* --- Pixiv 底部导航栏开始 --- */
#pixiv-nav-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color);
    z-index: 50;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease-in-out;
    padding: 10px;
    box-sizing: border-box;
}

body.dark-mode #pixiv-nav-bar {
    background-color: rgba(30, 30, 30, 0.85);
}

/* 复用顶部的隐藏逻辑（向移出屏幕） */
#pixiv-nav-bar.nav-hidden {
    transform: translateY(100%);
}

.pixiv-nav-tabs {
    display: flex;
    justify-content: space-around;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.pixiv-tab {
    cursor: pointer;
    padding: 8px 20px;
    font-weight: bold;
    color: var(--text-sub);
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.pixiv-tab.active {
    color: var(--accent-color);
    border-bottom: 2px solid var(--accent-color);
}

#pixiv-ranking-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

#pixiv-ranking-controls select, #pixiv-ranking-controls input {
    padding: 5px;
    border-radius: 5px;
    border: 1px solid var(--border-input);
    background: var(--bg-input);
    color: var(--text-main);
}
/* --- Pixiv 底部导航栏结束 --- */
/* Pixiv 关注图标开始 */
.artist-follow-icon {
    /* 1. 修复颜色：使用 color 配合 SVG 里的 currentColor */
    color: rgba(112, 112, 112, 0.55);
    /* 2. 修复裁剪：允许 SVG 内容溢出容器（针对 scale 效果） */
    overflow: visible !important;

    transition: color 0.2s ease, transform 0.1s ease;
    /* 这里的 fill 可以去掉，改用 color 更稳妥 */
    fill: currentColor;
}

/* 鼠标悬停 */
.artist-follow-icon:hover {
    color: #a0a0a0;
    transform: scale(1.15); /* 稍微加大一点缩放感 */
}

/* 已关注的激活样式 (黄色) */
.artist-follow-icon.active {
    color: #f1c40f;
}

/* 激活并悬停时 */
.artist-follow-icon.active:hover {
    color: #f39c12;
}
/* Pixiv 关注图标结束 */
/* 播放图标叠加层 (视频专用) */
.play-icon-overlay {
    position: absolute;
    bottom: 0.5rem;
    left: 0.5rem;
    width: 38px;
    height: 38px;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5; /* 确保在图片上方 */
    opacity: 0.9;
    transition: all 0.2s ease-in-out;
    /* 关键修改：使播放图标可点击，不再穿透 */
    pointer-events: auto; /* <--- 重点修改这里 */
    border: 2px solid white;
}
/* 鼠标悬停效果 - 修正：现在只在悬停播放按钮本身时触发 */
.play-icon-overlay:hover {
    /* 赋予比父级效果更高的视觉优先级，并确保手型光标 */
    background-color: rgba(0, 0, 0, 0.95); /* 更暗，更明显 */
    transform: scale(1.1); /* 放大效果更明显 */
    opacity: 1; /* 确保不透明度最高 */
    cursor: pointer; /* 确保光标显示为手型 */
}

/* 移除原有的通过父级悬停触发播放按钮样式，或者将其保留但弱化效果 */
.post a:hover .play-icon-overlay {
    /* 保持原样式，或将其删除，让上面的 :hover 生效 */
    background-color: rgba(0, 0, 0, 0.6);
    transform: scale(1);
    opacity: 0.9;
}
/* 播放图标 (三角形) 样式 */
.play-icon-overlay svg {
    /* 调整三角形位置使其看起来更居中 */
    transform: translateX(1px);
}

.post-source-line {
    display: flex;
    align-items: center; /* 垂直居中对齐图标和文本 */
    gap: 5px; /* 图标和艺术家名称之间的间距 */
    min-height: 18px; /* 强制图标显示 */
    flex-shrink: 0;   /* 不允许被压缩 */
}

.source-icon {
    width: 16px;
    height: 16px;
    vertical-align: middle; /* 确保图标与文本基线对齐 */
    border-radius: 2px;
}

.source-icon {
    width: 16px !important;
    height: 16px !important;
    flex-shrink: 0;
}

.source-with-id {
    display: flex;
    align-items: center;
    gap: 4px;        /* 图标与文本的间距，越小越“紧贴” */
}

.rating-nsfw {
    border: 2px solid #ff3b3b !important;
    box-shadow: 0 0 6px rgba(255, 0, 0, 0.6);
}
/* Header 左侧 AI 任务区域 */
.ai-task-manager {
    position: relative;
    cursor: pointer;
    margin-right: 5px;
    color: var(--text-sub);
}
.ai-task-manager:hover {
    color: var(--accent-color);
}
.ai-badge {
    position: absolute;
    top: -5px;
    right: -8px;
    background-color: var(--accent-color);
    color: white;
    font-size: 0.7rem;
    padding: 2px 5px;
    border-radius: 10px;
    display: none; /* 默认隐藏 */
}
.ai-badge.active {
    display: block;
}
.ai-badge.finished {
    background-color: #28a745; /* 绿色 */
}

/* Post Action 中的 AI 按钮 */
.ai-trans-btn {
    cursor: pointer;
    color: var(--text-sub);
    fill: currentColor;
    transition: all 0.2s;
    /* 防止长按选中文字 */
    -webkit-user-select: none;
    user-select: none;
    /* 防止移动端长按弹出系统菜单和高亮 */
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}
body.dark-mode .ai-trans-btn {
    color: var(--text-header);
}
.ai-trans-btn:hover {
    color: #9b59b6; /* 紫色代表魔法/AI */
    transform: scale(1.1);
}
.ai-trans-btn.processing {
    animation: spin 2s infinite linear;
    color: var(--accent-color);
}
/* --- 遮罩选区弹窗 --- */
.mask-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.mask-modal-content {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mask-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 20px;
    border-radius: 8px;
    color: #fff;
    pointer-events: auto;
}

.mask-instruction {
    font-size: 14px;
}

.mask-actions {
    display: flex;
    gap: 10px;
}

.mask-actions button {
    padding: 5px 15px;
    font-size: 14px;
    height: auto;
}

.mask-actions button.secondary {
    background-color: #6c757d;
}

.mask-image-container {
    position: relative;
    overflow: auto;
    max-height: 85vh; /* 留出顶部工具栏空间 */
    border: 2px solid #555;
    /* 禁用默认拖拽，方便我们的点击逻辑 */
    user-select: none;
    -webkit-user-drag: none;
}

.mask-content-wrapper {
    position: relative;
    width: fit-content;
    min-width: 100%;
}

#mask-target-image {
    display: block;
    max-width: 100%;
    height: auto;
    /* 防止图片被拖拽 */
    pointer-events: none;
}

.mask-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* 绘制的遮罩框 */
.mask-box {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.5);
    pointer-events: none; /* 让点击穿透，方便继续操作 */
}

/* 临时绘制中的框 */
.mask-box.drawing {
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px dashed rgba(255, 255, 255, 0.8);
}