#panel[data-local-tool] {
    overflow: hidden;
}

.tool-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

#toolMain.card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
}

.ai-image-tool {
    display: flex;
    flex-direction: row;
    gap: 16px;
    height: 100%;
    flex: 1;
    min-height: 0;
}

.ai-image-sidebar {
    width: 340px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
    background: var(--app-glass-strong, rgba(255,255,255,0.86));
    border: 1px solid var(--app-line, rgba(0,0,0,0.08));
    border-radius: 12px;
    padding: 16px;
    min-height: 0;
}

.ai-image-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    background: var(--app-glass-strong, rgba(255,255,255,0.86));
    border: 1px solid var(--app-line, rgba(0,0,0,0.08));
    border-radius: 12px;
}

.ai-image-header h2 {
    margin: 0 0 4px;
    font-size: 17px;
    font-weight: 700;
}

.ai-image-header p {
    margin: 0;
    color: var(--chat-muted, #888);
    font-size: 12px;
}

.ai-image-input-area {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-image-input-area textarea {
    padding: 10px 12px;
    border: 1px solid var(--chat-border, #ddd);
    border-radius: 10px;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    outline: none;
    background: var(--chat-surface, #fff);
    color: var(--chat-text, #333);
    line-height: 1.5;
    min-height: 80px;
    height: 80px;
}

.ai-image-input-area textarea:focus {
    border-color: var(--chat-accent, #26a884);
}

.generate-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    background: var(--chat-accent, #26a884);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity .2s;
}

.generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.generate-btn:not(:disabled):hover {
    opacity: 0.85;
}

.ai-image-result {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 16px;
}

.ai-image-result-header {
    font-size: 13px;
    font-weight: 600;
    color: var(--chat-muted, #888);
    padding: 10px 16px;
    border-bottom: 1px solid var(--chat-border, #eee);
    flex-shrink: 0;
}

.ai-image-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--chat-muted, #aaa);
    font-size: 13px;
}

.ai-image-empty-icon {
    margin-bottom: 10px;
}

.ai-image-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.ai-image-display img,
.ai-image-display video {
    max-width: 100%;
    max-height: 55vh;
    border-radius: 10px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.08);
}

.ai-image-prompt {
    font-size: 12px;
    color: var(--chat-muted, #888);
    text-align: center;
    max-width: 360px;
    word-break: break-word;
}

.ai-image-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 8px;
    color: var(--chat-muted, #888);
    font-size: 13px;
}

.ai-image-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #e74c3c;
    font-size: 13px;
    text-align: center;
}

.ai-image-gallery {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: max-content;
    gap: 8px;
}

.ai-image-sidebar .ai-image-gallery {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    align-content: start;
}

.gallery-item {
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color .2s;
    background: var(--chat-surface, #f5f5f5);
    display: flex;
    flex-direction: column;
}

.gallery-item:hover {
    border-color: var(--chat-accent, #26a884);
}

.gallery-item img {
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: cover;
    display: block;
    background: #f0f0f0;
}

.video-gallery .gallery-item img {
    aspect-ratio: 16/9;
}

.video-thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #1a1a2e;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-play-icon {
    opacity: 0.7;
}

.gallery-item:hover .video-play-icon {
    opacity: 1;
}

.gallery-item-prompt {
    padding: 4px 6px;
    font-size: 10px;
    color: var(--chat-text, #333);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: var(--chat-surface, #f5f5f5);
}

.gallery-item-time {
    padding: 2px 6px 4px;
    font-size: 9px;
    color: var(--chat-muted, #aaa);
    background: var(--chat-surface, #f5f5f5);
}

.task-list {
    padding: 0;
    flex-shrink: 0;
}

.task-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--chat-muted, #888);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.task-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 6px;
    background: var(--chat-surface, #f5f5f5);
    font-size: 11px;
    margin-bottom: 4px;
}

.task-done {
    opacity: 0.6;
}

.task-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.task-dot-active {
    background: var(--chat-accent, #26a884);
    animation: taskPulse 1.2s infinite;
}

.task-dot-done {
    background: var(--chat-muted, #aaa);
}

@keyframes taskPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.task-prompt {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.task-timer {
    font-size: 10px;
    color: var(--chat-muted, #aaa);
    flex-shrink: 0;
}

.task-check {
    color: var(--chat-accent, #26a884);
    flex-shrink: 0;
    font-size: 12px;
}

.typing-dot {
    display: inline-block;
    animation: typingBounce 1.4s infinite ease-in-out both;
    font-size: 20px;
    padding: 0 2px;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }

@keyframes typingBounce {
    0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-6px); }
}

@media (max-width: 768px) {
    .ai-image-tool {
        flex-direction: column;
    }
    .ai-image-sidebar {
        width: 100%;
        max-height: auto;
    }
}
