﻿/* ========== 鏂囩敓鍥?========== */
html,
body {
    height: 100%;
}

body {
    background: #fff;
    overflow: hidden;
}

.image-tool-layout {
    display: grid;
    grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
    gap: 12px;
}

.ai-image-main {
    --image-card-height: 340px;
    --image-card-min-width: 300px;
    --image-card-media-ratio: 16 / 9;
    --image-card-media-max-height: 190px;
}

.image-form-panel,
.image-result-panel {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    min-width: 0;
}

.image-form-panel {
    padding: 16px;
}

.field-label {
    display: block;
    color: #1f2937;
    font-size: 0.88rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.image-prompt {
    width: 100%;
    min-height: 220px;
    resize: vertical;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    padding: 12px;
    line-height: 1.65;
    font-size: 0.92rem;
    color: #111827;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.image-prompt:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.image-prompt.is-login-required,
.image-prompt:disabled {
    cursor: not-allowed;
    border-color: #d1d5db;
    background: #f3f4f6;
    color: #94a3b8;
}

.image-prompt.is-login-required::placeholder,
.image-prompt:disabled::placeholder {
    color: #64748b;
    font-weight: 800;
}

.prompt-safety-hint {
    margin-top: 8px;
    padding: 9px 10px;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    background: #fff7ed;
    color: #9a3412;
    font-size: 0.78rem;
}

.prompt-safety-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    margin-bottom: 4px;
}

.prompt-safety-hint p {
    margin: 0;
    color: #7c2d12;
    line-height: 1.65;
}

.quick-prompt-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0 14px;
}

.quick-prompt {
    border: 1px solid #dbe3ef;
    background: #f8fafc;
    color: #334155;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 0.82rem;
    cursor: pointer;
}

.quick-prompt:hover {
    border-color: #93c5fd;
    color: #1d4ed8;
    background: #eff6ff;
}

.image-options-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.field-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-block span {
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 700;
}

.field-block select,
.field-block input {
    width: 100%;
    min-width: 0;
    height: 38px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    padding: 0 10px;
    background: #fff;
    color: #111827;
    outline: none;
    font-size: 0.86rem;
}

.field-block input.is-invalid,
.field-block select.is-invalid {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.field-error {
    display: block;
    min-height: 16px;
    color: #dc2626;
    font-size: 0.76rem;
    font-weight: 700;
    line-height: 1.35;
}

.field-error:empty {
    display: none;
}

.image-title-field {
    grid-column: 1 / -1;
}

.field-block optgroup {
    font-weight: 700;
}

.field-block option {
    font-weight: 400;
}

.ratio-field {
    position: relative;
}

.native-hidden-select {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.ratio-picker {
    position: relative;
}

.ratio-picker-trigger {
    width: 100%;
    min-width: 0;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    padding: 0 10px;
    background: #fff;
    color: #111827;
    font-size: 0.86rem;
    cursor: pointer;
}

.ratio-picker-trigger:focus {
    border-color: #2563eb;
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.ratio-trigger-side {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    color: #64748b;
}

.ratio-picker-menu {
    position: absolute;
    z-index: 40;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    display: none;
    max-height: 310px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
}

.ratio-picker.open .ratio-picker-menu {
    display: block;
}

.ratio-picker-option {
    width: 100%;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 0;
    border-radius: 6px;
    padding: 6px 8px;
    background: transparent;
    color: #334155;
    font-size: 0.84rem;
    cursor: pointer;
    text-align: left;
}

.ratio-picker-option:hover,
.ratio-picker-option[aria-selected="true"] {
    background: #eff6ff;
    color: #1d4ed8;
}

.ratio-option-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ratio-shape {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    border: 1.5px solid #2563eb;
    border-radius: 3px;
    background: #eff6ff;
}

.ratio-shape[data-ratio="auto"] {
    width: 26px;
    height: 18px;
    border-style: dashed;
    background: #f8fafc;
}

.ratio-shape[data-ratio="1:1"] { width: 22px; height: 22px; }
.ratio-shape[data-ratio="3:2"] { width: 28px; height: 19px; }
.ratio-shape[data-ratio="2:3"] { width: 19px; height: 28px; }
.ratio-shape[data-ratio="4:3"] { width: 28px; height: 21px; }
.ratio-shape[data-ratio="3:4"] { width: 21px; height: 28px; }
.ratio-shape[data-ratio="5:4"] { width: 28px; height: 22px; }
.ratio-shape[data-ratio="4:5"] { width: 22px; height: 28px; }
.ratio-shape[data-ratio="16:9"] { width: 34px; height: 19px; }
.ratio-shape[data-ratio="9:16"] { width: 19px; height: 34px; }
.ratio-shape[data-ratio="2:1"] { width: 34px; height: 17px; }
.ratio-shape[data-ratio="1:2"] { width: 17px; height: 34px; }
.ratio-shape[data-ratio="21:9"] { width: 36px; height: 15px; }
.ratio-shape[data-ratio="9:21"] { width: 15px; height: 36px; }

.reference-upload-block {
    margin-top: 12px;
}

.reference-upload-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.reference-upload-head .field-label {
    margin-bottom: 0;
}

.reference-upload-head span {
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 700;
}

.reference-upload-drop {
    min-height: 76px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    color: #334155;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.reference-upload-drop:hover {
    border-color: #93c5fd;
    background: #eff6ff;
    color: #1d4ed8;
}

.reference-upload-drop.is-disabled,
.reference-upload-drop:has(input:disabled) {
    cursor: not-allowed;
    opacity: 0.62;
}

.reference-upload-drop.is-disabled:hover,
.reference-upload-drop:has(input:disabled):hover {
    border-color: #cbd5e1;
    background: #f8fafc;
    color: #334155;
}

.reference-upload-drop input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.reference-upload-drop i {
    font-size: 1.15rem;
}

.reference-upload-drop span {
    font-size: 0.88rem;
    font-weight: 700;
}

.reference-upload-drop small {
    color: #64748b;
    font-size: 0.75rem;
}

.reference-preview-list {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.reference-preview-item {
    position: relative;
    aspect-ratio: 1 / 1;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    background: #f8fafc;
}

.reference-preview-item img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.reference-remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(15, 23, 42, 0.15);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #334155;
    cursor: pointer;
}

.reference-remove-btn:hover {
    color: #b91c1c;
    border-color: #fecaca;
    background: #fff1f2;
}

.image-credit-estimate {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    background: #fff7ed;
    color: #9a3412;
    font-size: 0.86rem;
    line-height: 1.4;
}

.image-credit-estimate i {
    color: #f97316;
}

.image-credit-estimate strong {
    font-size: 1rem;
}

.image-credit-estimate small {
    margin-left: auto;
    color: #c2410c;
    font-size: 0.76rem;
}

.image-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.primary-tool-btn,
.secondary-tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.18s ease;
}

.primary-tool-btn {
    flex: 1;
    border: 1px solid #2563eb;
    color: #fff;
    background: #2563eb;
}

.primary-tool-btn:hover:not(:disabled) {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.primary-tool-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.secondary-tool-btn {
    border: 1px solid #dbe3ef;
    background: #fff;
    color: #475569;
}

.secondary-tool-btn:hover {
    border-color: #93c5fd;
    color: #1d4ed8;
    background: #eff6ff;
}

.image-result-panel {
    display: flex;
    flex-direction: column;
    min-height: 520px;
}

.image-result-column {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.image-result-column .prompt-safety-hint {
    margin-top: 0;
}

.result-header {
    padding: 13px 16px;
    border-bottom: 1px solid #edf2f7;
}

.result-header h3 {
    margin: 0;
    color: #111827;
    font-size: 1rem;
}

.result-header p {
    margin: 4px 0 0;
    color: #64748b;
    font-size: 0.8rem;
}

.image-result-grid {
    flex: 1;
    padding: 14px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--image-card-min-width)), 1fr));
    gap: 12px;
    align-content: start;
}

.image-empty,
.image-loading {
    grid-column: 1 / -1;
    min-height: 360px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #94a3b8;
}

.image-empty i {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.55;
}

.image-loading .loading-spinner {
    width: 34px;
    height: 34px;
    border: 3px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

.generated-image-card {
    height: var(--image-card-height);
    min-height: var(--image-card-height);
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    display: flex;
    flex-direction: column;
}

.generated-image-pager {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #334155;
    font-size: 0.86rem;
    font-weight: 800;
}

.generated-image-page-btn {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #fff;
    color: #2563eb;
    cursor: pointer;
}

.generated-image-page-btn:disabled {
    cursor: not-allowed;
    color: #94a3b8;
    background: #f8fafc;
}

.generated-image-card-single {
    grid-column: 1 / -1;
    width: min(560px, 100%);
    justify-self: center;
}

.generated-image-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    color: #1d4ed8;
    font-size: 0.86rem;
}

.generated-image-card-head span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #334155;
    font-weight: 700;
}

.generated-image-preview,
.public-image-thumb {
    width: min(100%, calc(var(--image-card-media-max-height) * 16 / 9));
    display: block;
    aspect-ratio: var(--image-card-media-ratio);
    margin: 0 auto;
    padding: 0;
    border: 0;
    overflow: hidden;
    background: #f8fafc;
    cursor: zoom-in;
}

.generated-image-preview img,
.public-image-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    object-fit: contain;
    background: #f8fafc;
}

.generated-image-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: auto;
    padding: 10px;
}

.image-action-link,
.image-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    box-sizing: border-box;
}

.image-action-link {
    background: #2563eb;
    color: #fff;
    border: 0;
}

.image-action-btn {
    border: 1px solid #dbe3ef;
    background: #fff;
    color: #475569;
}

.image-error {
    grid-column: 1 / -1;
    padding: 14px;
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #991b1b;
    border-radius: 8px;
    font-size: 0.9rem;
}

.image-error-title {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.55;
}

.image-error-title i {
    margin-top: 3px;
}

.image-error-advice {
    margin: 10px 0 0 24px;
    padding: 0;
    color: #7f1d1d;
    line-height: 1.65;
}

.image-error-advice li + li {
    margin-top: 4px;
}

.image-success-meta {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid #bbf7d0;
    background: #f0fdf4;
    color: #166534;
    border-radius: 8px;
    font-size: 0.86rem;
    font-weight: 700;
}

.image-success-meta i {
    color: #16a34a;
}

.image-success-note {
    font-weight: 600;
}

.image-expiry-text {
    color: #dc2626;
    font-weight: 800;
}

.image-history-panel {
    border-top: 1px solid #edf2f7;
    background: #fbfdff;
}

.image-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid #edf2f7;
}

.image-history-header h3 {
    margin: 0;
    color: #111827;
    font-size: 0.96rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.image-history-header h3 i {
    color: #2563eb;
}

.history-refresh-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #fff;
    color: #475569;
    cursor: pointer;
}

.history-refresh-btn:hover {
    border-color: #93c5fd;
    color: #1d4ed8;
    background: #eff6ff;
}

.image-history-list {
    max-height: 320px;
    overflow-y: auto;
    padding: 10px 14px 14px;
}

.image-history-empty {
    padding: 14px;
    color: #94a3b8;
    font-size: 0.86rem;
    text-align: center;
}

.image-history-error {
    color: #991b1b;
}

.image-history-item {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    padding: 10px;
}

.image-history-item + .image-history-item {
    margin-top: 10px;
}

.image-history-meta {
    color: #64748b;
    font-size: 0.76rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.image-history-title {
    margin: 0 0 6px;
    color: #0f172a;
    font-size: 0.95rem;
    line-height: 1.35;
}

.image-history-prompt {
    margin: 0 0 8px;
    color: #1f2937;
    font-size: 0.86rem;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-action-list {
    display: grid;
    gap: 6px;
}

.history-image-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 700;
}

.history-image-actions.expired {
    color: #94a3b8;
}

.history-action-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: #2563eb;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 0.78rem;
    font-weight: 700;
    text-decoration: none;
}

.history-action-link:hover {
    border-color: #93c5fd;
    color: #1d4ed8;
    background: #eff6ff;
}

button.image-action-link,
button.history-action-link {
    font-family: inherit;
}

.image-public-status {
    cursor: default;
    user-select: none;
}

.image-public-toggle.is-public,
.image-public-status.is-public {
    background: #ecfdf5;
    border: 1px solid #bbf7d0;
    color: #15803d;
}

.image-public-toggle.is-private,
.image-public-status.is-private {
    background: #fff;
    border: 1px solid #dbe3ef;
    color: #475569;
}

.image-action-link.image-public-toggle:hover,
.history-action-link.image-public-toggle:hover {
    background: #f0fdf4;
    border-color: #86efac;
    color: #166534;
}


/* Standalone AI image page */

.ai-image-main {
    --image-library-toolbar-offset: 690px;
    --image-tabs-row-height: 35px;
    --image-page-side-padding: max(20px, calc((100vw - 1480px) / 2 + 20px));
    position: fixed;
    top: var(--site-nav-height, 54px);
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: none;
    height: auto;
    min-height: 0;
    margin: 0;
    padding: 10px var(--image-page-side-padding) 28px;
    overflow-y: auto;
    overscroll-behavior: contain;
    box-sizing: border-box;
    background: #fff;
}

body.ai-image-library-mode {
    overflow: hidden;
}

body.ai-image-library-mode .ai-image-main {
    height: auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

body.image-preview-open .ai-image-main,
body.image-prompt-modal-open .ai-image-main {
    overflow: hidden;
}

body.ai-image-library-mode .ai-image-tabs {
    flex: 0 0 auto;
    align-self: flex-start;
    width: fit-content;
    max-width: 100%;
}

body.ai-image-library-mode .ai-image-page-toolbar {
    flex: 0 0 auto;
}

body.ai-image-library-mode .ai-image-tab-panel.active {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.ai-image-page-toolbar {
    width: 100%;
    max-width: 1200px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 14px;
}

.ai-image-tabs {
    display: inline-flex;
    align-items: center;
    gap: 0;
    width: fit-content;
    margin-bottom: 0;
    padding: 3px;
    background: #f1f5f9;
    border: 0;
    border-radius: 8px;
}

.ai-credit-purchase-btn {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 16px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #f8fafc;
    color: #334155;
    font-size: 0.9rem;
    font-weight: 800;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: none;
    transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.ai-credit-purchase-btn:hover {
    border-color: #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
}

.ai-image-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    height: auto;
    padding: 0.4rem 0.5rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #64748b;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-image-tab:hover {
    color: #3b82f6;
    background: rgba(255, 255, 255, 0.5);
}

.ai-image-tab:focus {
    outline: none;
}

.ai-image-tab:focus-visible {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.ai-image-tab.active {
    background: #fff;
    color: #1d4ed8;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1);
}

.ai-image-tab i {
    font-size: 0.9rem;
    opacity: 0.9;
}

.ai-image-tab-panel[hidden] {
    display: none !important;
}

.ai-image-tab-panel {
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.ai-image-workbench {
    display: grid;
    grid-template-columns: minmax(380px, 0.76fr) minmax(640px, 1.24fr);
    gap: 14px;
    align-items: start;
}

.ai-image-section-head,
.public-gallery-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.ai-image-section-head h1,
.public-gallery-head h2 {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    color: #0f172a;
    font-size: 1.35rem;
    line-height: 1.2;
}

.ai-image-section-head h1 i,
.public-gallery-head h2 i {
    color: #2563eb;
}

.ai-image-section-head p,
.public-gallery-head p {
    margin: 4px 0 0;
    color: #64748b;
    font-size: 0.9rem;
}

.ai-image-credit-badge {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 13px;
    border: 1px solid #fed7aa;
    border-radius: 999px;
    background: #fff7ed;
    color: #c2410c;
    font-weight: 800;
    font-size: 0.86rem;
}

.ai-image-main .image-form-panel,
.ai-image-main .image-result-panel,
.ai-image-main .image-result-column {
    min-width: 0;
}

.public-gallery-section {
    margin-top: 0;
}

body.ai-image-library-mode .public-gallery-section,
body.ai-image-library-mode .image-library-shell {
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.image-library-shell {
    display: grid;
    gap: 8px;
}

body.ai-image-library-mode .image-library-shell {
    grid-template-rows: auto minmax(0, 1fr);
}

.image-library-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 520px);
    gap: 18px;
    align-items: center;
    padding: 12px;
    border: 1px solid #e3eaf4;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.05);
}

.ai-image-tab-panel[data-ai-image-tab-panel="gallery"] .image-library-hero,
.ai-image-tab-panel[data-ai-image-tab-panel="mine"] .image-library-hero {
    width: calc(100% - var(--image-library-toolbar-offset));
    height: var(--image-tabs-row-height);
    min-height: var(--image-tabs-row-height);
    margin: calc(-1 * (var(--image-tabs-row-height) + 14px)) 0 14px var(--image-library-toolbar-offset);
    padding: 4px 12px;
    box-sizing: border-box;
    grid-template-columns: 150px minmax(360px, 1fr);
    gap: 14px;
    align-items: center;
}

.ai-image-tab-panel[data-ai-image-tab-panel="gallery"] .image-library-shell,
.ai-image-tab-panel[data-ai-image-tab-panel="mine"] .image-library-shell {
    gap: 0;
}

.ai-image-tab-panel[data-ai-image-tab-panel="gallery"] .image-library-kicker,
.ai-image-tab-panel[data-ai-image-tab-panel="mine"] .image-library-kicker {
    display: none;
}

.ai-image-tab-panel[data-ai-image-tab-panel="gallery"] .image-library-heading h1,
.ai-image-tab-panel[data-ai-image-tab-panel="mine"] .image-library-heading h1 {
    font-size: 1rem;
    line-height: 1;
}

.image-library-heading {
    min-width: 0;
}

.image-library-kicker {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 5px;
    color: #2563eb;
    font-size: 0.76rem;
    font-weight: 900;
}

.image-library-heading h1 {
    margin: 0;
    color: #0f172a;
    font-size: 1.1rem;
    line-height: 1.1;
}

.image-library-heading p {
    margin: 6px 0 0;
    color: #64748b;
    font-size: 0.9rem;
    line-height: 1.5;
}

.image-library-heading strong {
    color: #2563eb;
}

.image-library-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.image-library-layout {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

body.ai-image-library-mode .image-library-layout {
    height: 100%;
    min-height: 0;
    align-items: stretch;
}

.image-library-sidebar {
    position: sticky;
    top: 78px;
    display: grid;
    gap: 10px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid #e3eaf4;
    border-radius: 8px;
    align-self: start;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.04);
}

body.ai-image-library-mode .image-library-sidebar {
    position: static;
    max-height: 100%;
    overflow-y: auto;
}

.image-library-sidebar-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 2px 4px 6px;
    border-bottom: 1px solid #edf2f7;
}

.image-library-sidebar-head span {
    color: #0f172a;
    font-size: 0.9rem;
    font-weight: 900;
}

.image-library-sidebar-head small {
    color: #94a3b8;
    font-size: 0.74rem;
    font-weight: 700;
}

.image-library-sidebar-head small strong {
    color: #2563eb;
    font-size: 0.9rem;
    font-weight: 900;
}

.image-library-total {
    color: #334155;
    font-size: 0.9rem;
}

.image-library-total strong {
    color: #0f172a;
    font-size: 1.15rem;
}

.image-library-search {
    height: 40px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 13px;
    border: 1px solid #d9e4f2;
    border-radius: 8px;
    background: #f8fafc;
    color: #64748b;
}

.image-library-search:focus-within {
    border-color: #2563eb;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.image-library-search input {
    min-width: 0;
    width: 100%;
    border: 0;
    outline: none;
    color: #0f172a;
    font-size: 0.9rem;
    background: transparent;
}

.image-library-filters {
    display: grid;
    gap: 4px;
}

.image-filter-chip {
    position: relative;
    min-height: 36px;
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 0 8px;
    background: transparent;
    color: #475569;
    font-size: 0.86rem;
    font-weight: 800;
    cursor: pointer;
    text-align: left;
}

.image-filter-chip i {
    width: 18px;
    color: #64748b;
    text-align: center;
}

.image-filter-count {
    min-width: 24px;
    height: 20px;
    margin-left: auto;
    padding: 0 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #eef2f7;
    color: #64748b;
    font-size: 0.74rem;
    font-weight: 900;
}

.image-filter-chip:hover {
    background: #f3f7fd;
    color: #1d4ed8;
}

.image-filter-chip.active {
    border-color: #c9ddff;
    background: #edf5ff;
    color: #1d4ed8;
}

.image-filter-chip.active::before {
    content: "";
    width: 3px;
    height: 18px;
    border-radius: 999px;
    background: #2563eb;
}

.image-filter-chip.active i {
    color: #2563eb;
}

.image-filter-chip.active .image-filter-count {
    background: #dbeafe;
    color: #1d4ed8;
}

.image-library-refresh {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 14px;
    border: 1px solid #d9e4f2;
    border-radius: 8px;
    background: #fff;
    color: #334155;
    font-weight: 800;
    cursor: pointer;
}

.image-library-refresh:hover {
    border-color: #93c5fd;
    color: #1d4ed8;
    background: #eff6ff;
}

.image-library-content {
    min-width: 0;
    height: calc(100vh - 145px);
    min-height: 420px;
    display: flex;
    flex-direction: column;
}

body.ai-image-library-mode .image-library-content {
    height: auto;
    min-height: 0;
    overflow: hidden;
}

.public-image-gallery {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
    align-content: start;
    gap: 16px;
    overflow-y: auto;
    padding: 1px 4px 72px 1px;
}

.public-image-card {
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid #e3eaf4;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.public-image-card:hover,
.public-image-card:focus-within {
    border-color: #bfdbfe;
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.1);
    transform: translateY(-2px);
}

.public-image-media {
    position: relative;
    background: #f8fafc;
    border-bottom: 1px solid #edf2f7;
}

.public-image-thumb img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    padding: 10px;
    box-sizing: border-box;
    background: #f8fafc;
}

.public-image-file-type {
    position: absolute;
    top: 10px;
    left: 10px;
    display: inline-flex;
    align-items: center;
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #92400e;
    font-size: 0.7rem;
    font-weight: 900;
    line-height: 1.2;
    white-space: nowrap;
    box-shadow: 0 5px 15px rgba(15, 23, 42, 0.08);
}

.public-image-actions {
    position: absolute;
    right: 10px;
    bottom: 10px;
    left: 10px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.public-image-card:hover .public-image-actions,
.public-image-card:focus-within .public-image-actions {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.public-image-actions .public-image-download,
.public-image-actions .public-image-prompt-btn,
.public-image-actions .image-action-link,
.public-image-actions .image-delete-button {
    width: 100%;
    min-height: 34px;
    padding: 0 10px;
    border-radius: 7px;
    font-size: 0.82rem;
    font-weight: 900;
    box-sizing: border-box;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.public-image-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid #2563eb;
    background: #2563eb;
    color: #fff;
    text-decoration: none;
}

.public-image-prompt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    border: 1px solid rgba(203, 213, 225, 0.82);
    background: transparent;
    color: #334155;
    cursor: pointer;
}

.public-image-actions .public-image-prompt-btn {
    box-shadow: none;
}

.public-image-download:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.public-image-prompt-btn:hover {
    border-color: #94a3b8;
    color: #0f172a;
    background: transparent;
}

.public-image-prompt-btn:disabled {
    opacity: 0.48;
    cursor: not-allowed;
}

.image-delete-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid #fecaca;
    background: rgba(255, 255, 255, 0.94);
    color: #dc2626;
    cursor: pointer;
}

.image-delete-button:hover {
    background: #fef2f2;
    border-color: #fca5a5;
}

.image-delete-button:disabled {
    cursor: wait;
    opacity: 0.72;
}

.public-image-body {
    padding: 12px;
    flex: 1;
    min-height: 104px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.public-image-body p {
    margin: 0;
}

.public-image-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.public-image-title {
    min-width: 0;
    color: #0f172a;
    font-size: 0.96rem;
    font-weight: 900;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.public-image-id-row {
    line-height: 1;
}

.public-image-id {
    display: inline-block;
    color: #94a3b8;
    font-size: 0.73rem;
    font-weight: 800;
    vertical-align: middle;
    white-space: nowrap;
}

.public-image-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: #64748b;
    font-size: 0.78rem;
    line-height: 1.2;
}

.public-image-meta-right {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}

.public-image-author {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    overflow: hidden;
}

.public-image-author span {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.public-image-author i {
    color: #94a3b8;
    flex-shrink: 0;
}

.public-image-subject {
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #475569;
    font-size: 0.7rem;
    font-weight: 900;
    line-height: 1.2;
    white-space: nowrap;
    flex-shrink: 0;
}

.public-image-subject[data-subject="primary-math"] {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #15803d;
}

.public-image-subject[data-subject="junior-math"] {
    border-color: #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
}

.public-image-subject[data-subject="senior-math"] {
    border-color: #ddd6fe;
    background: #f5f3ff;
    color: #6d28d9;
}

.public-image-subject[data-subject="junior-physics"] {
    border-color: #fed7aa;
    background: #fff7ed;
    color: #c2410c;
}

.public-image-subject[data-subject="senior-physics"] {
    border-color: #fecaca;
    background: #fff1f2;
    color: #be123c;
}

.public-image-subject[data-subject="college-math"] {
    border-color: #c7d2fe;
    background: #eef2ff;
    color: #4338ca;
}

.public-image-subject[data-subject="college-physics"] {
    border-color: #a7f3d0;
    background: #ecfdf5;
    color: #047857;
}

.public-image-subject[data-subject="chinese"] {
    border-color: #fde68a;
    background: #fffbeb;
    color: #92400e;
}

.public-image-subject[data-subject="english"] {
    border-color: #bae6fd;
    background: #f0f9ff;
    color: #0369a1;
}

.public-image-subject[data-subject="advertising"] {
    border-color: #fbcfe8;
    background: #fdf2f8;
    color: #be185d;
}

.public-image-downloads {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #059669;
    font-weight: 900;
    flex-shrink: 0;
}

.public-image-extra-meta,
.public-image-card-foot {
    color: #94a3b8;
    font-size: 0.73rem;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.public-image-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: auto;
}

.my-image-card .public-image-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.my-image-card .public-image-download {
    background: #2563eb;
    color: #fff;
}

/* Match the AI video library card treatment. */
.public-image-gallery {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--image-card-min-width)), 1fr));
    gap: 14px;
    align-items: start;
    grid-auto-rows: auto;
}

.public-image-card {
    min-width: 0;
    height: var(--image-card-height);
    min-height: var(--image-card-height);
    align-self: stretch;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    display: flex;
    flex-direction: column;
    box-shadow: none;
    transform: none;
}

.public-image-card:hover,
.public-image-card:focus-within {
    border-color: #e5e7eb;
    box-shadow: none;
    transform: none;
}

.public-image-media {
    position: relative;
    display: grid;
    place-items: center;
    background: #fff;
    border-bottom: 1px solid #edf2f7;
}

.public-image-featured-badge {
    position: absolute;
    left: 8px;
    top: 8px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 8px 16px rgba(146, 64, 14, 0.18);
    pointer-events: none;
}

.public-image-featured-badge i {
    font-size: 10px;
}

.public-image-thumb {
    position: relative;
    display: block;
    width: min(100%, calc(var(--image-card-media-max-height) * 16 / 9));
    aspect-ratio: var(--image-card-media-ratio);
    border: 0;
    padding: 0;
    margin: 0 auto;
    overflow: hidden;
    background: #fff;
    cursor: zoom-in;
}

.public-image-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    padding: 0;
    object-fit: contain;
    background: #fff;
}

.public-image-body {
    padding: 10px 12px;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 6px;
    overflow: hidden;
}

.my-image-card .public-image-body {
    min-height: 0;
}

.public-image-title {
    color: #111827;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.public-image-id-row {
    line-height: 1;
}

.public-image-id {
    display: inline-block;
    background: #e0e7ff;
    color: #4f46e5;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 700;
    font-family: Consolas, Monaco, monospace;
    vertical-align: middle;
    white-space: nowrap;
}

.public-image-file-type {
    position: static;
    top: auto;
    left: auto;
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
    padding: 1px 5px;
    border-radius: 3px;
    background: #fef3c7;
    color: #92400e;
    font-size: 10px;
    font-weight: 800;
    line-height: 1.4;
    vertical-align: middle;
    white-space: nowrap;
    box-shadow: none;
}

.public-image-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #64748b;
    font-size: 0.76rem;
    line-height: 1.2;
}

.public-image-meta-right {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}

.public-image-author {
    display: flex;
    align-items: center;
    gap: 4px;
    max-width: 58%;
    min-width: 0;
    overflow: hidden;
}

.public-image-author span {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.public-image-subject {
    padding: 2px 7px;
    border: 0;
    border-radius: 8px;
    background: #6a9fa8;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

.public-image-subject[data-subject="primary-math"] {
    background: #7fa87f;
    color: #fff;
}

.public-image-subject[data-subject="junior-math"] {
    background: #6b8cae;
    color: #fff;
}

.public-image-subject[data-subject="senior-math"] {
    background: #9585a8;
    color: #fff;
}

.public-image-subject[data-subject="junior-physics"] {
    background: #c9a86c;
    color: #fff;
}

.public-image-subject[data-subject="senior-physics"] {
    background: #b87b7b;
    color: #fff;
}

.public-image-subject[data-subject="college-math"] {
    background: #7c6fb0;
    color: #fff;
}

.public-image-subject[data-subject="college-physics"] {
    background: #4f8f9f;
    color: #fff;
}

.public-image-subject[data-subject="chinese"] {
    background: #b7791f;
    color: #fff;
}

.public-image-subject[data-subject="english"] {
    background: #3b82f6;
    color: #fff;
}

.public-image-subject[data-subject="advertising"] {
    background: #db2777;
    color: #fff;
}

.public-image-downloads {
    color: #10b981;
}

.public-image-extra-meta {
    color: #94a3b8;
    font-size: 0.72rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.public-image-actions,
.my-image-card .public-image-actions {
    position: static;
    right: auto;
    bottom: auto;
    left: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 6px;
    padding: 0;
    opacity: 1;
    pointer-events: auto;
    transform: none;
}

.public-image-card:hover .public-image-actions,
.public-image-card:focus-within .public-image-actions {
    transform: none;
}

.public-image-actions .public-image-download,
.public-image-actions .public-image-prompt-btn,
.public-image-actions .image-action-link,
.public-image-actions .image-delete-button {
    width: 100%;
    min-height: 32px;
    padding: 0 10px;
    border-radius: 7px;
    font-size: 0.82rem;
    font-weight: 800;
    box-shadow: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.public-image-download,
.my-image-card .public-image-download,
.public-image-actions .image-action-link {
    border: 0;
    background: #eef2ff;
    color: #1d4ed8;
}

.public-image-download:hover,
.my-image-card .public-image-download:hover,
.public-image-actions .image-action-link:hover,
.public-image-actions .image-action-link.image-public-toggle:hover {
    background: #dbeafe;
    color: #1d4ed8;
}

.public-image-actions .image-public-status.is-public {
    background: #ecfdf5;
    border: 1px solid #bbf7d0;
    color: #15803d;
}

.public-image-actions .image-public-status.is-private {
    background: #fff;
    border: 1px solid #dbe3ef;
    color: #475569;
}

.public-image-prompt-btn {
    border: 1px solid #dbe3ef;
    background: transparent;
    color: #334155;
}

.public-image-prompt-btn:hover {
    border-color: #94a3b8;
    color: #0f172a;
    background: transparent;
}

.image-delete-button {
    border: 0;
    background: #fef2f2;
    color: #b91c1c;
}

.image-delete-button:hover {
    background: #fee2e2;
}

.image-preview-open {
    overflow: hidden;
}

.image-prompt-modal-open {
    overflow: hidden;
}

.image-preview-modal[hidden] {
    display: none !important;
}

.image-preview-modal {
    --image-preview-top-offset: calc(var(--site-nav-height, 54px) + 1px);
    --image-preview-padding: clamp(8px, 2vh, 22px);
    position: fixed;
    top: var(--image-preview-top-offset);
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: var(--image-preview-padding);
    box-sizing: border-box;
}

.image-preview-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.62);
}

.image-preview-dialog {
    position: relative;
    z-index: 1;
    width: calc(100vw - 2 * var(--image-preview-padding));
    height: calc(100vh - var(--image-preview-top-offset) - 2 * var(--image-preview-padding));
    height: calc(100dvh - var(--image-preview-top-offset) - 2 * var(--image-preview-padding));
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.32);
}

.image-preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid #e5e7eb;
}

.image-preview-modal-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #0f172a;
}

.image-preview-toolbar-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    flex: 0 0 auto;
}

.image-preview-close {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #fff;
    color: #334155;
    cursor: pointer;
}

.image-preview-zoom-btn {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #fff;
    color: #334155;
    cursor: pointer;
}

.image-preview-zoom-btn:hover,
.image-preview-close:hover {
    border-color: #93c5fd;
    color: #1d4ed8;
    background: #eff6ff;
}

.image-preview-prompt-btn {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0 10px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: transparent;
    color: #334155;
    font-size: 0.84rem;
    font-weight: 800;
    cursor: pointer;
}

.image-preview-prompt-btn:hover,
.image-preview-prompt-btn.active {
    border-color: #94a3b8;
    color: #0f172a;
    background: transparent;
}

.image-preview-prompt-btn:disabled {
    opacity: 0.48;
    cursor: not-allowed;
}

.image-preview-stage {
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    background: #f8fafc;
    padding: 12px;
    box-sizing: border-box;
    touch-action: none;
    cursor: default;
    user-select: none;
}

.image-preview-stage.is-zoomed {
    cursor: grab;
}

.image-preview-stage.is-dragging {
    cursor: grabbing;
}

.image-preview-modal-img {
    display: block;
    max-width: calc(100% - 24px);
    max-height: calc(100% - 24px);
    width: auto;
    height: auto;
    object-fit: contain;
    transform-origin: center center;
    will-change: transform;
    user-select: none;
    -webkit-user-drag: none;
}

.image-preview-modal-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 8px;
    background: #2563eb;
    color: #fff;
    font-size: 0.84rem;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.image-download-confirm-modal {
    --image-download-confirm-top-offset: calc(var(--site-nav-height, 54px) + 1px);
    position: fixed;
    top: var(--image-download-confirm-top-offset);
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1020;
    display: grid;
    place-items: center;
    padding: clamp(14px, 4vw, 28px);
    box-sizing: border-box;
}

.image-download-confirm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(3px);
}

.image-download-confirm-dialog {
    position: relative;
    z-index: 1;
    width: min(430px, 100%);
    display: grid;
    gap: 14px;
    padding: 22px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
}

.image-download-confirm-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    display: inline-grid;
    place-items: center;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: transparent;
    color: #475569;
    cursor: pointer;
}

.image-download-confirm-close:hover {
    border-color: #cbd5e1;
    color: #0f172a;
    background: transparent;
}

.image-download-confirm-icon {
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: #f8fafc;
    color: #0f172a;
    font-size: 1rem;
}

.image-download-confirm-content {
    display: grid;
    gap: 8px;
}

.image-download-confirm-kicker {
    margin: 0;
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 800;
}

.image-download-confirm-content h2 {
    margin: 0;
    color: #0f172a;
    font-size: 1.22rem;
    line-height: 1.25;
}

.image-download-confirm-content p {
    margin: 0;
    color: #475569;
    font-size: 0.92rem;
    line-height: 1.65;
}

.image-download-confirm-content strong {
    color: #0f172a;
}

.image-download-confirm-note {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    width: fit-content;
    max-width: 100%;
    padding: 7px 10px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    color: #475569;
    font-size: 0.84rem;
    font-weight: 700;
}

.image-download-confirm-note i {
    color: #b45309;
}

.image-download-confirm-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.image-download-confirm-secondary,
.image-download-confirm-primary {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 14px;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 800;
    cursor: pointer;
}

.image-download-confirm-secondary {
    border: 1px solid #dbe3ef;
    background: transparent;
    color: #334155;
}

.image-download-confirm-secondary:hover {
    border-color: #94a3b8;
    color: #0f172a;
    background: transparent;
}

.image-download-confirm-primary {
    border: 1px solid #111827;
    background: #111827;
    color: #fff;
}

.image-download-confirm-primary:hover {
    border-color: #0f172a;
    background: #0f172a;
}

.image-prompt-modal[hidden] {
    display: none !important;
}

.image-prompt-modal {
    --image-prompt-modal-top-offset: calc(var(--site-nav-height, 54px) + 1px);
    position: fixed;
    top: var(--image-prompt-modal-top-offset);
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1010;
    display: grid;
    place-items: center;
    padding: clamp(14px, 4vw, 28px);
    box-sizing: border-box;
}

.image-prompt-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(4px);
}

.image-prompt-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(620px, 100%);
    max-height: min(620px, calc(100vh - var(--image-prompt-modal-top-offset) - 40px));
    max-height: min(620px, calc(100dvh - var(--image-prompt-modal-top-offset) - 40px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

.image-prompt-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid #e5e7eb;
    background: transparent;
}

.image-prompt-modal-title {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: #0f172a;
    font-size: 1rem;
    font-weight: 900;
}

.image-prompt-modal-close {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: transparent;
    color: #334155;
    cursor: pointer;
}

.image-prompt-modal-close:hover {
    border-color: #cbd5e1;
    color: #0f172a;
    background: transparent;
}

.image-prompt-modal-body {
    min-height: 0;
    overflow: auto;
    padding: 18px;
    background: transparent;
}

.image-prompt-modal-text {
    margin: 0;
    color: #334155;
    font-size: 0.95rem;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
}

.image-prompt-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 18px;
    border-top: 1px solid #e5e7eb;
    background: transparent;
}

.image-prompt-modal-copy,
.image-prompt-modal-done {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 800;
    cursor: pointer;
}

.image-prompt-modal-copy {
    border: 1px solid #dbe3ef;
    background: transparent;
    color: #334155;
}

.image-prompt-modal-copy:hover {
    border-color: #94a3b8;
    color: #0f172a;
    background: transparent;
}

.image-prompt-modal-copy.copied {
    border-color: #86efac;
    background: transparent;
    color: #047857;
}

.image-prompt-modal-copy:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.image-prompt-modal-done {
    border: 1px solid #dbe3ef;
    background: transparent;
    color: #334155;
}

.image-prompt-modal-done:hover {
    border-color: #94a3b8;
    color: #0f172a;
    background: transparent;
}

.public-gallery-empty {
    grid-column: 1 / -1;
    min-height: 180px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 12px;
    padding: 28px 18px;
    color: #64748b;
    text-align: center;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.public-gallery-empty i {
    color: #2563eb;
    font-size: 28px;
}

.public-gallery-empty p {
    margin: 0;
    font-weight: 700;
}

.gallery-pagination-container {
    flex: 0 0 auto;
    position: fixed;
    bottom: 0;
    left: calc(18px + 232px + 16px);
    right: 18px;
    z-index: 30;
    padding: 10px 0 12px;
    margin-top: auto;
    border-top: 1px solid #e3eaf4;
    background: #fff;
    backdrop-filter: blur(8px);
}

body.ai-image-library-mode .gallery-pagination-container {
    position: relative;
    inset: auto;
    z-index: 1;
    padding: 10px 0 0;
    margin-top: 0;
}

.gallery-pagination-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

.gallery-pagination-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #e5e7eb;
    background: #fff;
    border-radius: 8px;
    color: #64748b;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.gallery-pagination-btn:hover:not(:disabled) {
    border-color: #2563eb;
    color: #2563eb;
    background: #eff6ff;
}

.gallery-pagination-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.gallery-pagination-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
    opacity: 1;
}

.gallery-pagination-ellipsis,
.gallery-pagination-info {
    color: #94a3b8;
    font-size: 13px;
}

.gallery-pagination-info {
    margin: 0 8px;
}

.gallery-pagination-jump-inline {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #64748b;
    font-size: 13px;
}

.gallery-pagination-jump-inline input {
    width: 52px;
    height: 30px;
    padding: 0 6px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #334155;
    font-size: 13px;
    text-align: center;
    outline: none;
    -moz-appearance: textfield;
    appearance: textfield;
}

.gallery-pagination-jump-inline input::-webkit-outer-spin-button,
.gallery-pagination-jump-inline input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.gallery-pagination-jump-inline input:focus {
    border-color: #2563eb;
}

.gallery-jump-btn {
    height: 30px;
    padding: 0 12px;
    border: 1px solid #2563eb;
    background: #2563eb;
    color: #fff;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 1120px) {
    .ai-image-workbench {
        grid-template-columns: 1fr;
    }

    .ai-image-tab-panel[data-ai-image-tab-panel="gallery"] .image-library-hero,
    .ai-image-tab-panel[data-ai-image-tab-panel="mine"] .image-library-hero {
        width: 100%;
        height: auto;
        min-height: var(--image-tabs-row-height);
        margin: 0 0 14px;
        grid-template-columns: minmax(160px, 0.5fr) minmax(360px, 1fr);
    }

    .ai-image-tab-panel[data-ai-image-tab-panel="gallery"] .image-library-shell,
    .ai-image-tab-panel[data-ai-image-tab-panel="mine"] .image-library-shell {
        gap: 8px;
    }

    .public-image-gallery {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--image-card-min-width)), 1fr));
    }
}

@media (max-width: 900px) {
    .ai-image-main {
        --image-page-side-padding: 16px;
        padding-top: 8px;
        padding-bottom: 16px;
    }

    .ai-image-page-toolbar {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .ai-image-tabs {
        display: flex;
        width: 100%;
        overflow-x: auto;
    }
}

@media (max-width: 760px) {
    .ai-image-main {
        --image-page-side-padding: 12px;
        padding-top: 8px;
        padding-bottom: 12px;
    }

    .ai-image-page-toolbar {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .ai-credit-purchase-btn {
        width: 100%;
    }

    .ai-image-tab {
        flex: 1 1 0;
        min-width: 0;
        width: auto;
    }

    .ai-image-tab span {
        display: none;
    }

    .ai-image-tab i {
        font-size: 14px;
    }

    .image-preview-modal {
        padding: 10px;
    }

    .image-preview-modal-download {
        width: 100%;
    }

    .image-prompt-modal {
        padding: 12px;
    }

    .image-prompt-modal-footer {
        flex-direction: column;
    }

    .image-prompt-modal-copy,
    .image-prompt-modal-done {
        width: 100%;
    }

    .image-preview-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .image-preview-toolbar-actions {
        width: 100%;
    }

    .ai-image-section-head,
    .public-gallery-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .image-library-hero {
        grid-template-columns: 1fr;
        gap: 14px;
        padding: 14px;
    }

    .ai-image-tab-panel[data-ai-image-tab-panel="gallery"] .image-library-hero,
    .ai-image-tab-panel[data-ai-image-tab-panel="mine"] .image-library-hero {
        width: 100%;
        min-height: 0;
        margin: 0;
        grid-template-columns: 1fr;
    }

    .ai-image-tab-panel[data-ai-image-tab-panel="gallery"] .image-library-kicker,
    .ai-image-tab-panel[data-ai-image-tab-panel="mine"] .image-library-kicker {
        display: inline-flex;
    }

    .ai-image-tab-panel[data-ai-image-tab-panel="gallery"] .image-library-heading h1,
    .ai-image-tab-panel[data-ai-image-tab-panel="mine"] .image-library-heading h1 {
        font-size: 1.45rem;
    }

    .ai-image-tab-panel[data-ai-image-tab-panel="gallery"] .image-library-heading p,
    .ai-image-tab-panel[data-ai-image-tab-panel="mine"] .image-library-heading p {
        margin-top: 6px;
        white-space: normal;
    }

    .image-library-toolbar {
        grid-template-columns: 1fr;
    }

    .public-image-gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .image-library-layout {
        grid-template-columns: 1fr;
    }

    .image-library-sidebar {
        position: static;
    }

    .image-library-content {
        height: calc(100vh - 190px);
        min-height: 360px;
    }

    .gallery-pagination-container {
        left: 12px;
        right: 12px;
    }

    .image-library-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .public-image-actions {
        position: static;
        opacity: 1;
        pointer-events: auto;
        transform: none;
        padding: 0;
        margin-top: 6px;
    }

    .public-image-card:hover,
    .public-image-card:focus-within {
        transform: none;
    }
}

@media (max-width: 520px) {
    .ai-image-tab {
        flex: 1 1 0;
        min-width: 0;
    }

    .public-image-gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        padding-right: 1px;
        padding-left: 1px;
    }

    .public-image-card {
        height: 248px;
        min-height: 248px;
    }

    .public-image-media {
        min-height: 96px;
    }

    .public-image-thumb {
        width: 100%;
    }

    .public-image-body {
        padding: 8px;
        gap: 5px;
    }

    .public-image-title {
        font-size: 0.82rem;
        line-height: 1.25;
    }

    .public-image-id,
    .public-image-file-type,
    .public-image-subject {
        font-size: 9px;
    }

    .public-image-meta,
    .public-image-extra-meta,
    .public-image-card-foot {
        font-size: 0.68rem;
    }

    .public-image-author {
        max-width: 52%;
    }

    .public-image-actions,
    .my-image-card .public-image-actions {
        gap: 5px;
    }

    .public-image-actions .public-image-download,
    .public-image-actions .public-image-prompt-btn,
    .public-image-actions .image-action-link,
    .public-image-actions .image-delete-button {
        min-height: 28px;
        padding: 0 6px;
        font-size: 0.72rem;
    }
}

@media (max-width: 760px) {
    .image-options-grid {
        grid-template-columns: 1fr;
    }

    .reference-preview-list {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .image-credit-estimate {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .image-credit-estimate small {
        width: 100%;
        margin-left: 24px;
    }
}

@media (max-width: 480px) {
    .reference-preview-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* ========== AI 鍒跺浘鎿嶄綔姝ラ鎸囧紩 ========== */
.ai-image-guide-entry {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 16px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 0.9rem;
    font-weight: 800;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.ai-image-guide-entry:hover {
    border-color: #93c5fd;
    background: #dbeafe;
    color: #1e40af;
}

.ai-image-guide-focus {
    position: fixed;
    z-index: 10020;
    pointer-events: none;
    border: 2px solid #fbbf24;
    border-radius: 8px;
    box-shadow:
        0 0 0 9999px rgba(15, 23, 42, 0.66),
        0 0 0 6px rgba(251, 191, 36, 0.18),
        0 16px 42px rgba(15, 23, 42, 0.26);
    transition: left 0.22s ease, top 0.22s ease, width 0.22s ease, height 0.22s ease;
}

.ai-image-guide-popover {
    position: fixed;
    z-index: 10030;
    padding: 16px;
    color: #172033;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 8px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.32);
    line-height: 1.6;
}

.ai-image-guide-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #64748b;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.ai-image-guide-close:hover {
    background: rgba(15, 23, 42, 0.06);
    color: #111827;
}

.ai-image-guide-kicker {
    padding-right: 28px;
    font-size: 12px;
    font-weight: 800;
    color: #2563eb;
}

.ai-image-guide-progress {
    height: 5px;
    margin: 8px 0 12px;
    overflow: hidden;
    background: #e5e7eb;
    border-radius: 999px;
}

.ai-image-guide-progress span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #f59e0b);
    border-radius: inherit;
    transition: width 0.2s ease;
}

.ai-image-guide-popover h3 {
    margin: 0 0 8px;
    color: #0f172a;
    font-size: 17px;
    line-height: 1.35;
    letter-spacing: 0;
}

.ai-image-guide-popover p {
    margin: 0;
    color: #475569;
    font-size: 14px;
}

.ai-image-guide-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}

.ai-image-guide-btn {
    min-height: 34px;
    padding: 7px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    color: #334155;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.ai-image-guide-btn:hover:not(:disabled) {
    border-color: #2563eb;
    color: #1d4ed8;
}

.ai-image-guide-btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.ai-image-guide-btn.primary {
    border-color: #2563eb;
    background: #2563eb;
    color: #ffffff;
}

.ai-image-guide-btn.primary:hover {
    border-color: #1d4ed8;
    background: #1d4ed8;
    color: #ffffff;
}

.ai-image-guide-btn.ghost {
    border-color: transparent;
    color: #64748b;
}

.ai-image-guide-btn.ghost:hover {
    background: #f8fafc;
    color: #334155;
}

@media (max-width: 900px) {
    .ai-image-guide-entry,
    .ai-credit-purchase-btn {
        width: 100%;
        margin-left: 0;
    }

    .ai-image-guide-popover {
        padding: 14px;
    }

    .ai-image-guide-actions {
        justify-content: stretch;
    }

    .ai-image-guide-btn {
        flex: 1 1 auto;
    }
}
