/* =========================================================================
 * 素笺图片灯箱（imgmodal）样式
 * 布局与 Tab 结构参考 candy 相册弹窗（左大图 + 工具栏 + 缩略图条 + 右 Tab 面板），
 * 视觉走素笺设计语言：暖金强调（--accent / --gold）、衬线标题（--serif）、
 * 深遮罩（--scrim）、纸感留白。token 全部引用 theme-vars.css，零硬编码（守禁六）。
 * ========================================================================= */

/* 弹窗遮罩 */
.sj-imgmodal {
    display: none !important;
    position: fixed !important;
    inset: 0;
    background: var(--scrim);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}
.sj-imgmodal.open { display: flex !important; }

/* 弹窗主体（左右分栏） */
.sj-im-box {
    display: flex;
    width: 92%;
    max-width: 1180px;
    height: 88vh;
    max-height: 840px;
    background: var(--bg);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-lg);
}

/* 关闭按钮（左上角，玻璃底） */
.sj-im-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10002;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--glass-light);
    border: none;
    color: var(--on-accent);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
}
.sj-im-close:hover { background: var(--glass-light-hover); }

/* ---------- 左侧图片区 ---------- */
.sj-im-left {
    flex: 1.4;
    min-width: 0;
    background: var(--ink);
    display: flex;
    flex-direction: column;
    position: relative;
}
.sj-im-imgwrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: default;
    touch-action: none;            /* 禁用浏览器默认手势，自己接管滚轮/拖拽/轻扫 */
    -ms-touch-action: none;
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.sj-im-imgwrap::-webkit-scrollbar { display: none; }
.sj-im-imgwrap img {
    max-width: 100%;
    max-height: 100%;
    display: block;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    transition: transform .2s ease;
    will-change: transform;        /* 拖拽/缩放用 transform，提示浏览器分层渲染 */
}
.sj-im-imgwrap img.zoomed {
    max-width: none !important;
    max-height: none !important;
    cursor: grab;
}
.sj-im-imgwrap img.zoomed:active,
.sj-im-imgwrap img.zooming { cursor: grabbing; }

/* 箭头 */
.sj-im-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--glass-light);
    border: none;
    color: var(--on-accent);
    font-size: 26px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s, transform .2s;
}
.sj-im-arrow:hover { background: var(--glass-light-hover); transform: translateY(-50%) scale(1.08); }
.sj-im-prev { left: 10px; }
.sj-im-next { right: 10px; }

/* 计数器（左上角内） */
.sj-im-counter {
    position: absolute;
    top: 16px;
    left: 22px;
    z-index: 10006;
    color: var(--on-accent);
    font-size: var(--fs-sm);
    background: var(--scrim-mid);
    padding: 4px 14px;
    border-radius: 20px;
}

/* 底部工具栏 */
.sj-im-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 14px;
    background: rgba(0, 0, 0, .42);
    color: var(--on-accent);
    font-size: var(--fs-xs);
    flex-shrink: 0;
}
.sj-im-toolbar button {
    background: rgba(255, 255, 255, .12);
    border: none;
    color: var(--on-accent);
    font-size: var(--fs-xs);
    padding: 5px 12px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: background .2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.sj-im-toolbar button:hover { background: rgba(255, 255, 255, .26); }
.sj-im-toolbar .sj-im-zoom-level {
    min-width: 46px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* 缩略图条（多图显示，单图自动隐藏） */
.sj-im-thumbs {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, .42);
    overflow-x: auto;
    justify-content: center;
    flex-shrink: 0;
}
.sj-im-thumbs:empty { display: none; }
.sj-im-thumbs .thumb {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    flex-shrink: 0;
    opacity: .55;
    transition: all .2s;
    object-fit: cover;
}
.sj-im-thumbs .thumb.active { border-color: var(--gold); opacity: 1; }
.sj-im-thumbs .thumb:hover { opacity: 1; }

/* ---------- 右侧 Tab 面板 ---------- */
.sj-im-right {
    width: 380px;
    min-width: 320px;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border-left: 1px solid var(--line);
    overflow: hidden;
}
.sj-im-tabbar {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--line);
    background: var(--bg-soft);
    flex-shrink: 0;
}
.sj-im-tab {
    flex: 1;
    padding: 14px 0;
    border: 0;
    background: transparent;
    color: var(--faint);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    font-family: var(--serif);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all .2s;
}
.sj-im-tab:hover { color: var(--ink); }
.sj-im-tab.active {
    color: var(--ink);
    border-bottom-color: var(--gold);
    background: var(--bg);
    font-weight: var(--fw-semibold);
}
/* 右侧关闭按钮（tab 行右侧内联） */
.sj-im-close-right {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: var(--radius-xs);
    transition: all .2s;
    flex-shrink: 0;
}
.sj-im-close-right:hover { background: var(--hx-ffeeee, rgba(210, 63, 63, .1)); color: var(--danger, #d23f3f); }

.sj-im-pane { display: none; padding: 16px 18px; overflow-y: auto; flex: 1; }
.sj-im-pane.active { display: block; }

/* 信息面板 */
.sj-im-title {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
    font-family: var(--serif);
    color: var(--ink);
    margin: 0 0 14px;
    line-height: 1.4;
}
.sj-im-meta {
    background: var(--bg-soft);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    margin-bottom: 14px;
}
.sj-im-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: var(--fs-sm);
    border-bottom: 1px solid var(--line);
}
.sj-im-row:last-child { border-bottom: 0; }
.sj-im-label { color: var(--faint); }
.sj-im-value { color: var(--ink); font-weight: var(--fw-medium); text-align: right; }
.sj-im-value a { color: var(--gold); text-decoration: none; }
.sj-im-value a:hover { text-decoration: underline; }

/* 当前图片标题 / 简介 */
.sj-im-imgblock { margin-bottom: 14px; }
.sj-im-imgblock[hidden] { display: none; }
.sj-im-imgblock-title {
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
    color: var(--ink);
    margin: 0 0 6px;
    line-height: 1.4;
}
.sj-im-imgblock-desc {
    font-size: var(--fs-sm);
    line-height: 1.7;
    color: var(--faint);
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

/* 作者 */
.sj-im-author {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0 10px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}
.sj-im-author-link { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.sj-im-author .av-wrap { width: 36px; height: 36px; flex-shrink: 0; border: 2px solid var(--line); border-radius: 50%; overflow: hidden; position: relative; }
.sj-im-author .av-wrap .av-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sj-im-author-name { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--ink); }

/* 互动按钮（喜欢 / 收藏 / 分享） */
.sj-im-actions {
    display: flex;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}
.sj-im-actions button {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid var(--line);
    border-radius: var(--radius-2, 8px);
    padding: 6px 14px;
    font-size: var(--fs-sm);
    color: var(--muted);
    cursor: pointer;
    transition: all .2s;
}
.sj-im-actions button:hover { background: var(--bg-soft); border-color: var(--line-strong, var(--line)); }
.sj-im-actions button.active.liked { color: var(--danger, #d23f3f); border-color: var(--danger, #d23f3f); }
.sj-im-actions button.active.collected { color: var(--gold); border-color: var(--gold); }

/* 查看详情链接 */
.sj-im-detaillink { padding: 12px 0 4px; flex-shrink: 0; }
.sj-im-detaillink a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--gold);
    font-size: var(--fs-sm);
    text-decoration: none;
}
.sj-im-detaillink a:hover { text-decoration: underline; }

/* 评论区（与全站 .sj-comments 视觉一致） */
.sj-im-comments {
    flex: 1;
    overflow-y: auto;
    padding-top: 8px;
    min-height: 80px;
}
.sj-im-comment-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--ink);
    padding: 10px 0 8px;
}
.sj-im-comment-input {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin-bottom: 12px;
}
.sj-im-avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--line);
}
.sj-im-comment-input textarea {
    flex: 1;
    border: 1px solid var(--line);
    border-radius: var(--radius-2, 8px);
    padding: 8px 10px;
    font-size: var(--fs-sm);
    resize: vertical;
    min-height: 40px;
    font-family: inherit;
    background: var(--bg);
    color: var(--ink);
}
.sj-im-comment-input textarea:focus { border-color: var(--gold); outline: none; }
.sj-im-comment-input button {
    background: var(--gold);
    color: var(--on-accent);
    border: none;
    border-radius: var(--radius-2, 8px);
    padding: 6px 14px;
    font-size: var(--fs-sm);
    cursor: pointer;
    flex-shrink: 0;
    transition: background .2s;
}
.sj-im-comment-input button:hover { background: var(--gold-hover); }
.sj-im-comment-input button:disabled { opacity: .6; cursor: default; }
.sj-im-login-tip { font-size: var(--fs-xs); color: var(--faint); padding: 8px 0; }
.sj-im-login-tip a { color: var(--gold); }

.sj-im-comment-list { margin: 4px 0 12px; }
.sj-im-comment-empty { font-size: var(--fs-xs); color: var(--faint); padding: 8px 0; text-align: center; }
.sj-im-comment-item { display: flex; gap: 8px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line); }
.sj-im-comment-item:last-child { border-bottom: none; }
.sj-im-ci-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 1px solid var(--line); }
.sj-im-ci-body { flex: 1; min-width: 0; }
.sj-im-ci-name { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--ink); margin-bottom: 2px; }
.sj-im-ci-content { font-size: var(--fs-sm); color: var(--muted); line-height: 1.5; word-break: break-word; }
.sj-im-ci-meta { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.sj-im-ci-time { font-size: var(--fs-xs2, 11px); color: var(--faint); }
.sj-im-ci-like, .sj-im-ci-reply {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--faint);
    font-size: var(--fs-xs);
    transition: color .2s;
}
.sj-im-ci-like:hover { color: var(--danger, #d23f3f); }
.sj-im-ci-like.active { color: var(--danger, #d23f3f); }
.sj-im-ci-reply:hover { color: var(--gold); }
.sj-im-ci-like svg, .sj-im-ci-reply svg { display: block; }
.sj-im-ci-like-count { font-variant-numeric: tabular-nums; }
.sj-im-ci-children { margin-top: 2px; margin-left: 14px; padding-left: 10px; border-left: 2px solid var(--line); }
.sj-im-ci-reply-form { display: none; margin-top: 8px; }
.sj-im-ci-reply-form textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-2, 8px);
    padding: 7px 9px;
    font-size: var(--fs-sm);
    resize: vertical;
    min-height: 36px;
    font-family: inherit;
    background: var(--bg);
    color: var(--ink);
}
.sj-im-ci-reply-form textarea:focus { border-color: var(--gold); outline: none; }
.sj-im-ci-reply-form .rf-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.sj-im-ci-reply-form .rf-cancel, .sj-im-ci-reply-form .rf-submit {
    border: none;
    border-radius: var(--radius-2, 8px);
    padding: 5px 12px;
    font-size: var(--fs-xs);
    cursor: pointer;
}
.sj-im-ci-reply-form .rf-cancel { background: var(--bg-soft); color: var(--muted); border: 1px solid var(--line); }
.sj-im-ci-reply-form .rf-submit { background: var(--gold); color: var(--on-accent); }
.sj-im-ci-reply-form .rf-submit:hover { background: var(--gold-hover); }
.sj-im-ci-reply-form .rf-submit:disabled { opacity: .6; cursor: default; }

/* 标注面板 */
.sj-im-anno-list { margin-bottom: 12px; }
.sj-im-anno-item {
    padding: 10px 12px;
    background: var(--bg-soft);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    font-size: var(--fs-sm);
    color: var(--ink);
    border-left: 3px solid var(--gold);
}
.sj-im-anno-item .sj-im-anno-meta { font-size: var(--fs-xs2, 11px); color: var(--faint); margin-top: 4px; }
.sj-im-anno-empty, .sj-im-related-empty {
    color: var(--faint);
    font-size: var(--fs-sm);
    text-align: center;
    padding: 24px 0;
}
.sj-im-anno-input textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-size: var(--fs-sm);
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
    background: var(--bg);
    color: var(--ink);
    box-sizing: border-box;
}
.sj-im-anno-input textarea:focus { border-color: var(--gold); outline: none; }
.sj-im-anno-input button {
    margin-top: 6px;
    background: var(--gold);
    color: var(--on-accent);
    border: 0;
    border-radius: var(--radius-sm);
    padding: 6px 14px;
    font-size: var(--fs-sm);
    cursor: pointer;
}

/* 相关面板 */
.sj-im-related-title {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    font-family: var(--serif);
    color: var(--ink);
    margin: 0 0 10px;
}
.sj-im-related-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    margin-bottom: 14px;
    padding-bottom: 0;
    border-bottom: 1px solid var(--line);
}
.sj-im-rpill {
    padding: 6px 10px;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    font-size: var(--fs-xs2, 11px);
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.sj-im-rpill:hover { color: var(--gold); }
.sj-im-rpill.active { color: var(--gold); border-bottom-color: var(--gold); }
.sj-im-related-item {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    text-decoration: none;
    color: var(--ink);
}
.sj-im-related-item:last-child { border-bottom: 0; }
.sj-im-related-item:hover { background: var(--bg-soft); }
.sj-im-related-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: var(--bg-soft);
    color: var(--muted);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    font-size: var(--fs-xs2, 11px);
    font-weight: var(--fw-semibold);
    font-family: var(--serif);
}
.sj-im-related-icon svg { width: 16px; height: 16px; }
.sj-im-related-icon.type-encyclopedia { background: var(--gold-soft); color: var(--gold); }
.sj-im-related-icon.type-album { background: var(--hx-fce7f3, #fce7f3); color: var(--hx-be185d, #be185d); }
.sj-im-related-icon.type-library { background: var(--hx-dbeafe, #dbeafe); color: var(--hx-1d4ed8, #1d4ed8); }
.sj-im-related-icon.type-timeline { background: var(--hx-dcfce7, #dcfce7); color: var(--hx-15803d, #15803d); }
.sj-im-related-icon.type-kg { background: var(--hx-ede9fe, #ede9fe); color: var(--hx-6d28d9, #6d28d9); }
.sj-im-related-body { flex: 1; min-width: 0; }
.sj-im-related-line1 { display: flex; align-items: baseline; gap: 6px; margin-bottom: 2px; }
.sj-im-related-name {
    font-size: var(--fs-sm);
    color: var(--ink);
    font-weight: var(--fw-medium);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}
.sj-im-related-author { font-size: var(--fs-xs); color: var(--muted); flex-shrink: 0; }
.sj-im-related-line2 { font-size: var(--fs-xs2, 11px); color: var(--faint); display: flex; gap: 8px; }

/* ---------- 响应式：小屏变上下布局 ---------- */
@media (max-width: 720px) {
    .sj-im-box { flex-direction: column; height: 100vh; max-height: 100vh; border-radius: 0; }
    .sj-im-right { width: 100%; min-width: auto; max-height: 44vh; border-left: none; border-top: 1px solid var(--line); }
    .sj-im-left { flex: 1; min-height: 40vh; }
}
