/* --- 1. 基础变量与全局 --- */
:root {
    --column-gap: 0.6rem;

    /* 白天模式 (Light Mode) 默认值 */
    --bg-body: #f4f7f6;
    --bg-card: #ffffff;
    --bg-input: #fdfdfd;
    --bg-status: #eee;
    --bg-tag: #e9ecef;
    --bg-tag-hover: #d1d9e0;
    --text-main: #333;
    --text-sub: #555;
    --text-label: #4a4a4a;
    --text-header: #2c3e50;
    --text-artist: #d9534f;
    --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);
}

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);
}

/* 全局 body */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    background-color: var(--bg-body);
    color: var(--text-main);
}

/* 通用 Header（可能被设置页面等使用） */
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;
}

/* 禁止图片容器等被选中/拖动 */
.img-container, .image-download-link {
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
    -webkit-user-drag: none !important;
}

/* --- 2. 主头部 (Fixed Header) --- */
#main-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    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;
}

body.dark-mode #main-header {
    background-color: rgba(30, 30, 30, 0.75) !important;
}

/* 头部隐藏 */
#main-header.header-hidden {
    transform: translateY(-100%);
}

body.dark-mode #main-header.header-hidden {
    background-color: rgba(30, 30, 30, 0.9) !important;
}

/* 头部左侧图标区 */
.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;
}

.header-icon:hover {
    background-color: var(--bg-tag);
    color: var(--accent-color);
}

/* --- 3. 帮助弹窗 --- */
.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;
}

/* --- 4. 遮罩选区弹窗 --- */
.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);
}

/* --- 5. 大图预览弹窗 --- */
#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;
    object-fit: contain;
}

.preview-tags-container {
    padding: 12px;
    background: transparent;
    overflow-y: auto;
    max-height: 30%;
    z-index: 1;
}

#preview-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.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;
}

.preview-tag:hover {
    filter: brightness(1.2);
    background: rgba(255, 255, 255, 0.2);
}

.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;
}

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);
}

/* --- 6. 状态栏 (Status Bar) --- */
#status-bar {
    position: fixed;
    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;
    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);
    opacity: 1;
    visibility: visible;
}

.status-bar-hidden {
    opacity: 0 !important;
    visibility: hidden !important;
    transform: translateY(-10px) scale(0.8);
}

#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;
}

#status-bar.error {
    background-color: transparent !important;
    color: rgba(220, 53, 69, 0.89) !important;
    border-color: rgba(220, 53, 69, 0.3) !important;
}

#status-bar.success {
    background-color: transparent !important;
    color: rgba(40, 167, 69, 0.89) !important;
    border-color: rgba(40, 167, 69, 0.3) !important;
}

/* 状态栏与 Header 联动：Header 隐藏时状态栏置顶 */
#main-header.header-hidden + #status-bar {
    top: 0;
    background-color: rgba(255, 255, 255, 0) !important;
}

body.dark-mode #status-bar {
    background-color: transparent !important;
    color: #ccc;
}

/* --- 7. 控制区域 (Controls) --- */
.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;
}

/* --- 8. Tag 输入框容器及联想 --- */
.tags-input-container {
    position: relative;
    height: 38px;
}

#tags-input {
    height: 100%;
    width: 100%;
    padding: 0.6rem;
    box-sizing: border-box;
    border: 1px solid var(--border-input);
}

.tag-suggestions {
    position: absolute;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    z-index: 1000;
    width: 100%;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
}

.suggestion-item {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--bg-status);
}

.suggestion-item:hover {
    background: var(--bg-tag-hover);
}

.suggestion-item .en-name {
    color: inherit;
    font-weight: bold;
}

.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 */
.suggestion-item.tag-cat-5 .en-name { color: #ff8a00; }  /* Meta / Style */

.suggestion-item .cn-name {
    color: var(--text-sub);
    font-size: 0.9em;
    margin-left: 8px;
}

.suggestion-item .post-count {
    color: #888;
    font-size: 0.8em;
}

/* 清空 Tags 按钮 */
#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;
}

#clear-tags-btn:hover {
    color: var(--text-main);
    background-color: var(--bg-tag-hover);
}

#clear-tags-btn:disabled {
    display: none;
}

/* --- 9. 常用 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;
}

/* --- 10. 分页栏 (Page Manager) --- */
.page-manager {
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 100;
    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;
}

.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;
}

/* --- 11. 帖子网格 (Waterfall Layout) --- */
.post-grid-container {
    width: 100%;
}

#post-grid {
    display: flex;
    flex-wrap: nowrap;
    gap: var(--column-gap);
    margin-bottom: 2rem;
    align-items: flex-start;
    min-height: 50vh;
}

#post-grid .column {
    flex-shrink: 0;
    flex-grow: 1;
    width: var(--column-width, 19%);
    display: flex;
    flex-direction: column;
    gap: var(--column-gap);
    transition: width 0.3s ease;
}

/* 单列模式 */
#post-grid.single-column-grid {
    display: block;
    width: 100%;
    column-count: initial;
    column-gap: initial;
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
}

.single-column-grid .column {
    width: 100% !important;
}

.single-column-wrapper {
    width: 100%;
    margin: 0 auto;
}

/* --- 12. 帖子卡片 (Post Item) --- */
.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;
    margin-bottom: var(--column-gap);
    width: 100%;
}

.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%;
    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;
}

.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 .info {
    padding: 10px;
    gap: 6px;
}

/* 信息头部：左侧文字 + 右侧收藏 */
.info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 8px;
}

.meta-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-grow: 1;
    min-width: 0;
    gap: 2px;
}

.post-item .artist {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-artist);
    white-space: nowrap;
    overflow: hidden;
    cursor: pointer;
    transition: color 0.2s;
}

.post-item .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);
}

/* 底部操作栏 */
.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);
    font-size: 0.75em;
    color: var(--text-sub);
}

.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);
}

.forward-btn.copied {
    color: #28a745 !important;
}

.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 .tags {
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--text-sub);
    max-height: 4.2em;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-all;
}

/* 收藏按钮区域 */
.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;
    margin-left: 10px;
    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;
}

/* 来源图标行 */
.post-source-line {
    display: flex;
    align-items: center;
    gap: 5px;
    min-height: 18px;
    flex-shrink: 0;
}

.source-icon {
    width: 16px !important;
    height: 16px !important;
    flex-shrink: 0;
    vertical-align: middle;
    border-radius: 2px;
}

.source-with-id {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* --- 13. 媒体预览附件 (GIF, 视频, Pool 标签) --- */
.preview-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-container img {
    -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-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;
}

/* Pixiv/Danbooru pool 计数标签 */
.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 {
    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;
}

/* 视频播放按钮 */
.play-icon-overlay {
    position: absolute;
    top: 80% !important;
    left: 20% !important;
    width: 2.5em;
    height: 2.5em;
    transform: translate(-50%, -50%) !important;
    pointer-events: auto;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    opacity: 0.9;
    transition: all 0.2s ease-in-out;
    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 {
    background-color: rgba(0, 0, 0, 0.6);
    transform: scale(1);
    opacity: 0.9;
}

.play-icon-overlay svg {
    transform: translateX(1px);
}

/* --- 14. 画师关注图标 --- */
.artist-follow-icon {
    color: rgba(112, 112, 112, 0.55);
    width: 1em;
    height: 1em;
    margin-left: 4px;
    cursor: pointer;
    vertical-align: -0.125em;
    max-height: 1em;
    max-width: 1em;
}

.artist-follow-icon:hover {
    color: #a0a0a0;
    transform: scale(1.15);
}

.artist-follow-icon.active,
.artist-follow-icon.followed {
    color: #f1c40f;
}

.artist-follow-icon.active:hover,
.artist-follow-icon.followed:hover {
    color: #f39c12;
}

/* --- 15. Rating NSFW 边框高亮 --- */
.rating-nsfw {
    border: 2px solid #ff3b3b !important;
    box-shadow: 0 0 6px rgba(255, 0, 0, 0.6);
}

/* --- 16. 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;
}

.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;
    transform: scale(1.1);
}

.ai-trans-btn.processing {
    animation: spin 2s infinite linear;
    color: var(--accent-color);
}

/* --- 17. 加载触发器 --- */
.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); }
}

/* --- 18. 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);
}

/* --- 19. 设置页面专用样式 --- */
.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;
    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;
}

/* --- 20. 响应式布局 (移动端 ≤ 768px) --- */
@media (max-width: 768px) {
    #main-header {
        overflow: visible;
        height: auto;
        min-height: 60px;
        padding: 5px 10px;
    }

    .page-manager {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 4px;
        margin-left: 5px;
        flex-shrink: 1;
        min-width: 0;
        max-width: none;
        z-index: 101;
    }

    .page-container {
        padding: 4px 6px;
        margin-right: 0;
        flex-shrink: 0;
        border-width: 1px;
    }

    .page-input {
        width: 35px;
        font-size: 1rem;
    }

    .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;
        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;
        max-width: 100%;
        box-sizing: border-box;
        height: 44px;
    }

    .tags-input-container {
        height: 44px !important;
    }

    .control-group label {
        font-size: 0.9rem;
        margin-bottom: 0.3rem;
    }
}

/* --- Pool Translate Selection Mode --- */
.pool-translate-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--bg-card);
    border-bottom: 2px solid var(--accent-color);
    box-shadow: 0 2px 8px var(--shadow-header);
    gap: 12px;
    flex-wrap: wrap;
}

.pool-translate-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--text-main);
}

.pool-translate-info #pool-translate-title {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pool-translate-info #pool-translate-count {
    color: var(--accent-color);
    white-space: nowrap;
}

.pool-translate-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pool-translate-actions button {
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 0.9rem;
    background: var(--bg-input);
    color: var(--text-main);
    transition: all 0.2s;
}

.pool-translate-actions button:hover {
    opacity: 0.85;
}

.pool-translate-actions button.primary {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.pool-translate-actions button.primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pool-translate-actions button.secondary {
    background: transparent;
    color: var(--text-sub);
    border-color: var(--border-color);
}

/* Pool 选择模式的每个帖子项 */
.pool-select-item {
    cursor: default;
}

.pool-select-item .img-container {
    position: relative;
    cursor: pointer;
}

.pool-select-checkbox {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 10;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.2s, transform 0.2s;
}

.pool-select-checkbox:hover {
    opacity: 1;
    transform: scale(1.1);
}

.pool-select-checkbox svg {
    width: 28px;
    height: 28px;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.4));
}

.pool-select-checkbox .check-mark {
    display: none;
}

.pool-select-checkbox.checked .check-mark {
    display: block;
}

.pool-select-item .info {
    padding: 4px 8px;
}

.pool-select-item .source-with-id {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-sub);
}