/* AI Image rebuild (2026-11-07) — kit tokens, scoped to #page-image.
 * Kit: bg #090b1d, surface #17112e, border #503183, primary #942aff,
 * pink #e347ed, cyan #21caff, text #f7f4ff, muted #a8a1c5.
 * Full-width: no max-width cap on #page-image, its workspace, or its
 * gallery. Grid/list view and batched rendering are wired in
 * generateImage.js (renderT2iGallery).
 */
#page-image {
    --ai-bg: #090b1d;
    --ai-surface: #17112e;
    --ai-border: #503183;
    --ai-primary: #942aff;
    --ai-pink: #e347ed;
    --ai-cyan: #21caff;
    --ai-text: #f7f4ff;
    --ai-muted: #a8a1c5;
}

/* ---------- Hero ---------- */
#page-image .ai-hero {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--ai-border);
    border-radius: 16px;
    padding: 28px 32px;
    margin-bottom: 16px;
    background:
        linear-gradient(100deg, rgba(9, 11, 29, 0.94) 0%, rgba(23, 17, 46, 0.78) 55%, rgba(148, 42, 255, 0.16) 100%),
        url('/static/img/ai-image/art/hero-waves.svg') center right / cover no-repeat,
        var(--ai-bg);
}
#page-image .ai-hero-content {
    position: relative;
    z-index: 1;
    max-width: 640px;
}
#page-image .ai-hero .page-title {
    background: linear-gradient(90deg, var(--ai-text) 0%, var(--ai-pink) 55%, var(--ai-primary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin: 0 0 6px;
}
#page-image .ai-hero .breadcrumb-page { margin: 0 0 6px; }
#page-image .ai-hero .page-subtitle { color: var(--ai-muted); margin: 0; }
#page-image .ai-hero-art {
    position: absolute;
    right: 24px;
    bottom: 0;
    height: 190px;
    width: auto;
    pointer-events: none;
    z-index: 0;
}

/* ---------- Mode bar ---------- */
#page-image .ai-mode-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 0 0 16px;
}
#page-image .ai-mode-bar .mode-toggle {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
#page-image .ai-mode-bar .mode-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    padding: 10px;
}
#page-image .ai-mode-bar .mode-btn img,
#page-image .mode-tab img {
    width: 22px;
    height: 22px;
    display: block;
}
#page-image .mode-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font: inherit;
}
#page-image .mode-btn.active,
#page-image .mode-tab.active {
    background: var(--ai-primary);
    border-color: var(--ai-primary);
}
#page-image .mode-btn.active img,
#page-image .mode-tab.active img {
    filter: brightness(0) invert(1);
}

/* ---------- Two-column workspace ---------- */
#page-image .ai-image-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
    margin-bottom: 16px;
}
#page-image .ai-panel {
    background: var(--ai-surface);
    border: 1px solid var(--ai-border);
    border-radius: 16px;
    padding: 20px;
}
#page-image .ai-panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}
#page-image .ai-panel-head img {
    width: 24px;
    height: 24px;
    flex: none;
}
#page-image .ai-panel-head h2 {
    font-size: 18px;
    margin: 0;
    color: var(--ai-text);
}

/* ---------- Fields ---------- */
#page-image .ai-field { margin-bottom: 14px; }
#page-image .ai-field > label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--ai-text);
}
#page-image .ai-field select,
#page-image .ai-field input[type="text"],
#page-image .ai-field textarea {
    width: 100%;
    background: #0d0f26;
    border: 1px solid var(--ai-border);
    color: var(--ai-text);
    border-radius: 10px;
    padding: 10px 12px;
    min-height: 44px;
    font-size: 15px;
}
#page-image .ai-field textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.5;
}
#page-image .ai-field select:focus,
#page-image .ai-field input[type="text"]:focus,
#page-image .ai-field textarea:focus {
    outline: 2px solid var(--ai-primary);
    outline-offset: 1px;
    border-color: var(--ai-primary);
}
#page-image .ai-field-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}
#page-image .ai-seed-row { display: flex; gap: 8px; }
#page-image .ai-seed-row input { flex: 1; min-width: 0; }
#page-image .ai-seed-row .btn-secondary { min-height: 44px; white-space: nowrap; }
#page-image .ai-counter {
    text-align: right;
    color: var(--ai-muted);
    font-size: 12px;
    margin-top: 4px;
}
#page-image .ai-hint {
    color: var(--ai-muted);
    font-size: 12px;
    margin-top: 4px;
}
#page-image .ai-prompt-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}
#page-image .ai-prompt-head label {
    font-weight: 600;
    color: var(--ai-text);
}
#page-image .ai-prompt-head .btn-enhance img {
    width: 16px;
    height: 16px;
    vertical-align: -3px;
    margin-right: 4px;
}

/* About / Advanced collapsibles */
#page-image .ai-details {
    border: 1px solid var(--ai-border);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 14px;
}
#page-image .ai-details summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--ai-text);
    min-height: 28px;
    list-style-position: inside;
}
#page-image .ai-details p {
    color: var(--ai-muted);
    margin: 8px 0 0;
    font-size: 14px;
    line-height: 1.55;
}

/* Execute CTA: kit primary, full width of the prompt panel */
#page-image #t2iWorkspace #generateImageBtn {
    width: 100%;
    background: var(--ai-primary);
    border-color: var(--ai-primary);
}
#page-image #generateImageBtn .btn-icon img {
    width: 16px;
    height: 16px;
    vertical-align: -2px;
}

/* Upload placeholders: kit icons instead of emoji */
#page-image .ai-upload-icon {
    width: 28px;
    height: 28px;
    margin-bottom: 8px;
}
#page-image .clipboard-btn img,
#page-image .ai-mode-bar .mode-btn img {
    vertical-align: middle;
}
#page-image .clipboard-btn img {
    width: 18px;
    height: 18px;
    margin-right: 6px;
}

/* ---------- Gallery ---------- */
#page-image .ai-gallery-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
#page-image .ai-gallery-actions,
#page-image .ai-gallery-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
#page-image .ai-search {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--ai-border);
    border-radius: 10px;
    padding: 0 10px;
    background: #0d0f26;
    min-height: 44px;
}
#page-image .ai-search img { width: 18px; height: 18px; flex: none; }
#page-image .ai-search input {
    border: 0;
    background: transparent;
    outline: none;
    color: var(--ai-text);
    min-height: 42px;
    width: 220px;
    font-size: 15px;
}
#page-image .ai-view-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--ai-border);
    background: transparent;
    color: var(--ai-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
#page-image .ai-view-btn img { width: 20px; height: 20px; }
#page-image .ai-view-btn.active {
    background: var(--ai-primary);
    border-color: var(--ai-primary);
    color: #fff;
}
#page-image .ai-view-btn.active img { filter: brightness(0) invert(1); }
#page-image .ai-gallery-count {
    color: var(--ai-muted);
    font-size: 13px;
}
#page-image .ai-show-more {
    margin: 16px auto 0;
    display: block;
    min-height: 44px;
}

/* Gallery empty states */
#page-image .ai-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--ai-muted);
}
#page-image .ai-empty img {
    max-width: 340px;
    width: 100%;
    height: auto;
    margin-bottom: 12px;
}
#page-image .ai-empty p { margin: 4px 0; }
#page-image .ai-empty p:first-of-type {
    color: var(--ai-text);
    font-weight: 600;
}

/* List view: rows with thumbnail, filename, inline actions */
#page-image #t2iGalleryGrid .gallery-item-name { display: none; }
#page-image #t2iGalleryGrid.ai-list-view {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
#page-image #t2iGalleryGrid.ai-list-view .gallery-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    aspect-ratio: auto;
}
#page-image #t2iGalleryGrid.ai-list-view .gallery-item > img {
    width: 96px;
    height: 64px;
    flex: none;
    border-radius: 8px;
}
#page-image #t2iGalleryGrid.ai-list-view .gallery-item-name {
    display: block;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ai-text);
    font-size: 14px;
}
#page-image #t2iGalleryGrid.ai-list-view .gallery-item-overlay {
    position: static;
    opacity: 1;
    display: flex;
    gap: 6px;
    background: none;
    padding: 0;
}
#page-image #t2iGalleryGrid.ai-list-view .gallery-item-delete {
    position: static;
    opacity: 1;
}
#page-image #t2iGalleryGrid.ai-list-view .gallery-item:hover { transform: none; }
#page-image .gallery-btn img { width: 18px; height: 18px; }


/* ---------- Image Edit mode: hide the Text to Image panel chrome ----------
 * The prompt field + Execute inside #t2iWorkspace are the shared
 * edit-instructions/execute surface for Image Edit: generateImage.js
 * startImageToImageGeneration() reads #t2iPrompt and is reached only via
 * #generateImageBtn, so the workspace itself must stay. What must not
 * render on the Image Edit tab is the Text to Image panel identity: its
 * heading, its About box, and the Generation Settings panel (the
 * /edit/process call sends only the prompt + ChronoEdit model, so those
 * settings are dead UI here). Keyed off the active tab, which
 * setImageMode() in app.js toggles; no JS change needed. Enhance and
 * Watermark already hide the whole workspace in setImageMode. */
#page-image:has(#imageToImageTab.active) #t2iWorkspace {
    grid-template-columns: minmax(0, 1fr);
}
#page-image:has(#imageToImageTab.active) #t2iWorkspace > .ai-panel + .ai-panel {
    display: none;
}
#page-image:has(#imageToImageTab.active) #t2iWorkspace > .ai-panel:first-child .ai-panel-head {
    display: none;
}
#page-image:has(#imageToImageTab.active) #t2iWorkspace .qa-feature-info {
    display: none;
}

/* ---------- Responsive ---------- */
@media (max-width: 1023px) {
    #page-image .ai-image-workspace {
        grid-template-columns: minmax(0, 1fr);
    }
}
@media (max-width: 900px) {
    #page-image .ai-hero-art { display: none; }
    #page-image .ai-hero-content { max-width: none; }
}
@media (max-width: 640px) {
    #page-image .ai-hero { padding: 20px; }
    #page-image .ai-panel { padding: 16px; }
    #page-image .ai-field-row { grid-template-columns: minmax(0, 1fr); }
    #page-image .ai-search input { width: 150px; }
}
