/* =============================================
   Image Viewer — 像素级复刻 image-viewer.html
   ============================================= */

/* ── 浮层 — 居中全屏 ── */
#ivOverlay {
    position: fixed;
    top: 50%; left: 50%;
    z-index: 1030;
    display: none;
    width: 100vw; height: 100dvh;
    transform: translate(-50%, -50%);
    flex-direction: column-reverse;
    justify-content: space-between;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.92);
}
@media (min-width: 1024px) {
    #ivOverlay { flex-direction: row; }
}
#ivOverlay.visible { display: flex; }

/* ── 关闭按钮 ── */
#ivClose {
    position: absolute;
    top: 17px; right: 17px;
    z-index: 10;
    display: flex;
    align-items: center; justify-content: center;
    width: 32px; height: 32px;
    border: none; border-radius: 50%;
    background: rgba(26, 26, 26, 0.85);
    color: #999;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}
#ivClose:hover { background: rgba(31, 31, 31, 0.9); color: #fff; }
#ivClose svg { width: 18px; height: 18px; }

/* ── 左侧：图片区 ── */
.iv-img-area {
    position: relative;
    display: flex;
    width: 100%; height: 100%;
    align-items: center; justify-content: center;
    overflow: hidden;
    cursor: default;
}
@media (min-width: 1024px) {
    .iv-img-area { padding: 1rem 5rem; }
}

.iv-img-inner {
    position: relative;
    display: flex;
    width: 100%; height: 100%;
    align-items: center; justify-content: center;
}

.iv-img-wrap {
    position: relative;
    max-height: 100%; max-width: 100%;
}

/* 虚化背景 */
.iv-img-blur {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
}

/* 主图链接 */
.iv-img-link {
    position: relative;
    z-index: 2;
    display: block;
    width: 100%; height: 100%;
    cursor: zoom-in;
}

.iv-img-main {
    z-index: 2;
    display: block;
    max-height: calc(100dvh - 2rem);
    max-width: 100%;
    object-fit: contain;
}

/* 底图（z-index -1，模糊效果预留） */
.iv-img-bg {
    position: absolute;
    top: 50%; left: 50%;
    z-index: -1;
    width: 100%; height: 100%;
    transform: translate(-50%, -50%);
    object-fit: contain;
}

/* ── 右侧栏 ── */
.iv-sidebar {
    flex-shrink: 0;
    display: none;
    flex-direction: column;
    gap: 1rem;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 1.5rem;
    background-color: #0f0f0f;
    border: 0.5px solid rgba(64, 64, 64, 0.5);
    color: #fff;
}
@media (min-width: 1024px) {
    .iv-sidebar {
        display: flex;
        width: 350px;
        min-width: 18vw;
        margin: 1rem 1rem 1rem 0;
        border-radius: 1.5rem;
    }
}

/* ── 区段：标题行 ── */
.iv-row {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
}
.iv-icon-box {
    display: flex;
    align-items: center; justify-content: center;
    padding: 0.25rem 0.375rem;
    border-radius: 0.375rem;
    background-color: #1f1f1f;
    color: #999;
}
.iv-icon-box svg { width: 10px; height: 10px; }

/* ── Prompt ── */
.iv-prompt-row { margin-top: 2rem; }
.iv-prompt-copy {
    margin-left: auto;
    font-size: 0.65rem;
    color: #6b6b6b;
    background: transparent;
    border: none; border-radius: 0.375rem;
    padding: 0.125rem 0.375rem;
    cursor: pointer;
    transition: color 0.2s, background-color 0.2s, transform 0.2s;
}
.iv-prompt-copy:hover { background-color: #1f1f1f; }
.iv-prompt-copy:active { transform: scale(0.98); }

.iv-prompt-wrap { margin: -0.5rem; display: flex; flex-direction: column; gap: 0.125rem; }

.iv-prompt-card {
    position: relative;
    display: flex;
    flex-shrink: 0;
    align-items: flex-start;
    gap: 1.5rem;
    overflow: hidden;
    padding: 0.5rem;
    border: 0.5px solid transparent;
    border-radius: 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b6b6b;
    text-align: left;
    background: transparent;
    cursor: pointer;
    user-select: text;
    transition: color 0.15s, background-color 0.15s, border-color 0.15s;
}
.iv-prompt-card:hover { color: #fff; background-color: #000; border-color: rgba(64, 64, 64, 0.5); }

.iv-prompt-thumb {
    width: 64px; height: 64px;
    flex-shrink: 0;
    border-radius: 0.375rem;
    object-fit: cover;
}

.iv-prompt-text {
    display: block;
    max-height: 8rem;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding-right: 0.5rem;
    font-size: 0.75rem;
    line-height: 1.625;
    scrollbar-width: thin;
    -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 24px), transparent);
    mask-image: linear-gradient(to bottom, black calc(100% - 24px), transparent);
}

/* ── 分隔线 ── */
.iv-hr {
    border: none;
    border-top: 0.5px solid rgba(255, 255, 255, 0.1);
    margin: 0;
}

/* ── Created ── */
.iv-created-value {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-left: auto;
}

.iv-history-btn {
    display: flex;
    align-items: center; justify-content: center;
    width: 1.5rem; height: 1.5rem;
    border: none; border-radius: 0.375rem;
    background: #1a1a1a;
    color: #999;
    cursor: pointer;
    transition: color 0.15s, background-color 0.15s;
}
.iv-history-btn:hover { background: #1f1f1f; color: #fff; }
.iv-history-btn svg { width: 12px; height: 12px; }

/* ── Tool 标签 ── */
.iv-tool-badge {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: auto;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    background-color: #1a1a1a;
    color: #999;
    font-size: 0.75rem;
    font-weight: 500;
}

/* ── 图像提示（参考图网格） ── */
.iv-ref-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.375rem;
}
.iv-ref-card {
    position: relative;
    aspect-ratio: 1;
    width: 100%;
    overflow: hidden;
    border-radius: 10px;
    cursor: pointer;
    background-size: cover;
    background-position: center;
    transition: transform 0.2s, box-shadow 0.2s, filter 0.2s;
}
.iv-ref-card:hover {
    z-index: 10;
    transform: scale(1.15) rotate(-1.5deg);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    filter: brightness(1.15);
}
.iv-ref-card img {
    width: 100%; height: 100%;
    object-fit: cover;
}

/* ── 操作按钮网格 ── */
.iv-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-top: auto;
}
.iv-btn {
    position: relative;
    display: flex;
    align-items: center; justify-content: center;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    border: none; border-radius: 10px;
    font-size: 0.75rem; line-height: 1rem; font-weight: 500;
    cursor: pointer;
    transition: background-color 0.1s;
}
.iv-btn svg { width: 14px; height: 14px; }

.iv-btn--action {
    background-color: oklch(48.8% .243 264.376);
    color: #fff;
}
.iv-btn--action:hover { background-color: oklch(40% 0.243 264.376); }

.iv-btn--dark {
    background-color: #141414;
    color: #fff;
}
.iv-btn--dark:hover { background-color: #1f1f1f; }

.iv-btn--danger {
    background-color: #141414;
    color: #fff;
}
.iv-btn--danger:hover { background-color: #dc2626; color: #fff; }

.iv-btn--disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.iv-btn--disabled:hover { background-color: #141414; }

[data-placeholder] {
    opacity: 0.35;
    pointer-events: none;
}
