/* ===== 右侧结果区 / 生成中加载画布 ===== */
/* ========== Right Panel ========== */
.right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.result-card {
    background: var(--card-bg);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-card);
    display: flex;
    flex-direction: column;
    min-height: 480px;
    flex: 1;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(61, 52, 40, 0.04);
}

.result-card-header {
    padding: 14px 20px;
    border-bottom: 1.5px solid var(--border-light);
    font-size: 14px;
    font-weight: 700;
    color: var(--text-heading);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.result-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 10px;
    padding: 40px 20px;
}

.result-empty-icon {
    width: 60px;
    height: 60px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    border: 2px dashed var(--border);
}

.result-empty-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-heading);
}

.result-empty-desc {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
    max-width: 300px;
}

.result-content {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
    align-content: start;
}

/* 注意：.result-content 是 flex 子项，交叉轴上的 auto margin 会吸走剩余空间、
   使宽度收缩到内容宽，必须先显式 width:100% 才能让 max-width 生效 */
.result-content.single-image,
.result-content.images-1 {
    display: flex;                 /* 单图居中；display 由 JS 同步置 flex（覆盖内联 grid） */
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: none;
}

/* 单图卡片尺寸由 fitSingleImage() 按原图比例计算：竖图贴可视高、横图贴可视宽，
   卡片始终紧贴图片，等比缩放不裁切、单张无需滚动 */
.result-content.single-image .image-block,
.result-content.images-1 .image-block {
    aspect-ratio: auto;
    width: 100%;           /* JS 未运行时的兜底：铺满宽度 */
    min-height: 220px;     /* 图片加载完成前占位，避免高度跳动 */
}

.result-content.single-image .image-preview-button,
.result-content.images-1 .image-preview-button {
    display: block;
    width: 100%;
    height: 100%;
}

.result-content.single-image .image-preview-button img,
.result-content.images-1 .image-preview-button img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* 两张：左右并排 */
.result-content.images-2 {
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
}

/* 四张：上二下二 */
.result-content.images-4 {
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
}

/* 三张：上一（居中，与下排等宽）下二 */
.result-content.images-3 {
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
}

.result-content.images-3 .image-block:first-child {
    grid-column: 1 / -1;
    width: calc(50% - 9px);   /* 减去 gap 的一半，与下排两张等宽 */
    justify-self: center;
}

.image-block {
    position: relative;
    border-radius: var(--radius-card);
    overflow: hidden;
    background: var(--card-bg);
    border: 2px solid var(--border-light);
    box-shadow: 0 2px 8px rgba(61, 52, 40, 0.05);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    aspect-ratio: 1 / 1;
}

.image-block:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(61, 52, 40, 0.12);
    border-color: var(--primary);
}

.image-block:hover .image-overlay {
    opacity: 1;
}

/* 预览按钮撑满整个格子，img 的 width:100% 才有参照（原先是无样式 button，会收缩到内容） */
.image-preview-button {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: none;
    cursor: zoom-in;
}

.image-block img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    background: var(--bg);
}

.image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: linear-gradient(transparent, rgba(114, 93, 66, 0.75));
    display: flex;
    justify-content: space-between;
    align-items: center;
    opacity: 0;
    transition: var(--transition);
}

.image-index {
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}

.image-actions {
    display: flex;
    gap: 6px;
}

.image-action-btn {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(8px);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.35);
    padding: 5px 14px;
    border-radius: var(--radius-btn);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    text-decoration: none;
    display: inline-block;
    letter-spacing: 0.02em;
}

.image-action-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
}

/* ===== 生成中：柔光显影画布 ===== */
/* 加载层覆盖结果区，出图时在其下方完成布局，再通过淡出实现原位显影。 */
.result-card {
    --result-header-height: 66px;
    position: relative;
}

.result-loading {
    position: absolute;
    z-index: 4;
    inset: var(--result-header-height) 0 0;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: clamp(24px, 3vh, 34px) clamp(24px, 4vw, 44px);
    overflow: auto;
    background:
        radial-gradient(circle at 52% 46%, rgba(15, 118, 110, .035), transparent 44%),
        var(--ds-surface);
    opacity: 1;
    transition: opacity 260ms cubic-bezier(.2, .8, .2, 1);
}

.result-loading.leaving {
    pointer-events: none;
    opacity: 0;
}

.generation-shell {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
    width: 100%;
    max-width: 620px;
    margin: auto;
}

.generation-head {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
}

.generation-mark {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid #cce6e0;
    border-radius: 12px;
    color: var(--ds-primary);
    background: #e6f4f1;
}

.generation-copy {
    min-width: 0;
}

.generation-title {
    overflow: hidden;
    color: var(--ds-ink);
    font-size: 15px;
    font-weight: 750;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.generation-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    margin-top: 5px;
    color: var(--ds-muted);
    font-size: 12px;
}

.generation-meta > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.generation-live-dot {
    width: 6px;
    height: 6px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--ds-primary);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, .10);
    animation: generationPulse 2.2s ease-in-out infinite;
}

.generation-elapsed {
    padding: 6px 9px;
    border: 1px solid var(--ds-line);
    border-radius: 9px;
    color: var(--ds-ink-soft);
    background: rgba(255, 255, 255, .82);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.skeleton-grid {
    display: grid;
    gap: 14px;
    width: 100%;
    max-width: 620px;
    margin: 0 auto;
}

.skeleton-grid.cols-1 {
    grid-template-columns: minmax(0, 1fr);
    max-width: min(100%, var(--single-tile-max, 560px));
}

.skeleton-grid.cols-2,
.skeleton-grid.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.skeleton-grid.cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.skeleton-grid.cols-3 .skeleton-tile:first-child {
    grid-column: 1 / -1;
    width: calc(50% - 7px);
    justify-self: center;
}

.skeleton-tile {
    position: relative;
    aspect-ratio: var(--tile-aspect, 1 / 1);
    min-height: 0;
    overflow: hidden;
    border: 1px solid #d9e6e1;
    border-radius: 22px;
    background: linear-gradient(145deg, #f6faf8 0%, #eef6f3 54%, #f5f4fb 100%);
    box-shadow: 0 18px 45px rgba(19, 41, 34, .08), inset 0 1px rgba(255, 255, 255, .8);
}

.tile-grid,
.tile-cloud,
.tile-light,
.tile-center {
    position: absolute;
}

.tile-grid {
    inset: 0;
    opacity: .45;
    background-image:
        linear-gradient(rgba(15, 118, 110, .035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 118, 110, .035) 1px, transparent 1px);
    background-size: 32px 32px;
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 25%, #000 75%, transparent);
    mask-image: linear-gradient(to bottom, transparent, #000 25%, #000 75%, transparent);
}

.tile-cloud {
    border-radius: 50%;
    filter: blur(8px);
    will-change: transform;
}

.tile-cloud-primary {
    top: -7%;
    left: -12%;
    width: 78%;
    height: 64%;
    background: radial-gradient(circle, rgba(55, 184, 167, .19), rgba(55, 184, 167, 0) 68%);
    animation: generationCloud 7s ease-in-out infinite alternate;
}

.tile-cloud-accent {
    right: -20%;
    bottom: -20%;
    width: 62%;
    height: 75%;
    background: radial-gradient(circle, rgba(112, 87, 217, .10), rgba(112, 87, 217, 0) 70%);
    animation: generationCloud 8.5s ease-in-out -2s infinite alternate-reverse;
}

.tile-light {
    z-index: 1;
    top: -20%;
    bottom: -20%;
    left: -48%;
    width: 28%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .76), transparent);
    filter: blur(2px);
    transform: skewX(-13deg);
    animation: generationLight 4.6s cubic-bezier(.4, 0, .2, 1) infinite;
    will-change: transform, opacity;
}

.skeleton-tile:nth-child(2) .tile-light { animation-delay: -.6s; }
.skeleton-tile:nth-child(3) .tile-light { animation-delay: -1.2s; }
.skeleton-tile:nth-child(4) .tile-light { animation-delay: -1.8s; }

.tile-center {
    z-index: 2;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 12px;
    color: var(--ds-ink-soft);
}

.tile-symbol {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    border: 1px solid rgba(15, 118, 110, .14);
    border-radius: 18px;
    color: var(--ds-primary);
    background: rgba(255, 255, 255, .70);
    box-shadow: 0 10px 30px rgba(15, 118, 110, .09);
    backdrop-filter: blur(10px);
}

.tile-label {
    font-size: 13px;
    font-weight: 650;
    letter-spacing: .02em;
}

.generation-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 0 2px;
    color: var(--ds-muted);
    font-size: 11.5px;
}

.generation-steps {
    display: flex;
    align-items: center;
    gap: 7px;
    flex: 0 0 auto;
}

.generation-step {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #8b9892;
    white-space: nowrap;
}

.generation-step i {
    width: 7px;
    height: 7px;
    border: 1.5px solid currentColor;
    border-radius: 50%;
    background: #fff;
}

.generation-step.is-done,
.generation-step.is-active {
    color: var(--ds-primary);
}

.generation-step.is-done i,
.generation-step.is-active i {
    background: var(--ds-primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, .09);
}

.generation-step-line {
    width: 22px;
    height: 1px;
    background: var(--ds-line);
}

.generation-note {
    text-align: right;
}

@keyframes generationLight {
    0% { opacity: 0; transform: translateX(0) skewX(-13deg); }
    18% { opacity: .9; }
    68%, 100% { opacity: 0; transform: translateX(550%) skewX(-13deg); }
}

@keyframes generationCloud {
    from { transform: translate3d(-2%, 0, 0) scale(.98); }
    to { transform: translate3d(9%, 5%, 0) scale(1.06); }
}

@keyframes generationPulse {
    50% { opacity: .45; transform: scale(.82); }
}

/* 明确选择比例时，多图结果沿用同一画幅，避免加载完成后的卡片跳变。 */
.result-content:not(.images-1):not(.single-image) .image-block {
    aspect-ratio: var(--result-aspect, 1 / 1);
}

/* 图片就地浮现（生成完成时） */
.result-content .image-block img {
    animation: imgReveal .45s ease both;
}

/* 转存换链接的二次渲染：图片已在屏上，跳过浮现动画避免整区闪烁 */
.result-content.no-reveal .image-block img {
    animation: none;
}

@keyframes imgReveal {
    from { opacity: 0; transform: scale(1.015); filter: blur(6px); }
    to   { opacity: 1; transform: scale(1); filter: blur(0); }
}

/* 历史列表里的耗时小标 */
.history-meta .gen-dur {
    color: var(--ds-primary);
}

@media (prefers-reduced-motion: reduce) {
    .tile-cloud,
    .tile-light,
    .generation-live-dot,
    .result-content .image-block img { animation: none; }
}

/* 消息提示 */
.toast {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    border: 2px solid;
}

.toast-error {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger);
}

.toast-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: var(--success);
}

/* 浮动通知 */
.toast-float {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 28px;
    border-radius: var(--radius-btn);
    font-size: 13px;
    font-weight: 600;
    z-index: 9999;
    pointer-events: none;
    animation: toastIn .3s cubic-bezier(0.4, 0, 0.2, 1),
               toastOut .3s cubic-bezier(0.4, 0, 0.2, 1) 2.7s forwards;
    box-shadow: 0 4px 16px rgba(61, 52, 40, 0.12);
    border: 2px solid;
    letter-spacing: 0.01em;
}

.toast-float.toast-error {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger);
}

.toast-float.toast-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: var(--success);
}

.toast-float.toast-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: var(--warning);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(-50%) translateY(0); }
    to   { opacity: 0; transform: translateX(-50%) translateY(-12px); }
}



