/* multi-image-tool.css */

.mit-main {
    max-width: 1000px;
    width: 100%;
    padding: 1.5rem 1rem 2rem;
}

/* ── Mode tabs ─────────────────────────────────────────────────────── */
.mode-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.mode-tab {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font-main);
    border: 1px solid var(--color-border, #ddd);
    border-radius: var(--radius-md, 6px);
    background: var(--color-surface, #fff);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.mode-tab:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.mode-tab.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.mode-description {
    text-align: center;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin: 0 0 1.25rem;
}

/* ── Drop zone ─────────────────────────────────────────────────────── */
.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border: 2px dashed var(--color-border, #ccc);
    border-radius: var(--radius-lg, 10px);
    padding: 2.5rem 2rem;
    cursor: pointer;
    transition: border-color 0.18s, background 0.18s;
    background: var(--color-surface, #fff);
    text-align: center;
    min-height: 160px;
    user-select: none;
}

.drop-zone:hover,
.drop-zone:focus,
.drop-zone.dragover {
    border-color: var(--color-primary, #4a90e2);
    background: rgba(74, 144, 226, 0.05);
    outline: none;
}

.drop-zone.dragover { border-style: solid; }
.drop-zone input[type="file"] { display: none; }

.drop-zone-icon {
    width: 48px;
    height: 48px;
    color: var(--color-text-muted, #aaa);
    margin-bottom: 0.25rem;
}

.drop-zone-text {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
}

.drop-zone-sub {
    font-size: 0.84rem;
    color: var(--color-text-muted);
}

/* ── Upload preview ────────────────────────────────────────────────── */
.upload-preview {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border, #ddd);
    border-radius: var(--radius-lg, 8px);
}

.upload-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
}

.upload-thumbs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.5rem;
}

.upload-thumb {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-md, 6px);
    overflow: hidden;
    border: 1px solid var(--color-border, #ddd);
    background: #f0f0f0;
}

.upload-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-thumb-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
}

.upload-thumb:hover .upload-thumb-remove { opacity: 1; }
.upload-thumb-remove:hover { background: #c0392b; }

.upload-thumb-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2px 4px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 0.65rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Settings panels ───────────────────────────────────────────────── */
.settings-panel {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border, #ddd);
    border-radius: var(--radius-lg, 8px);
}

.setting-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.6rem;
    flex-wrap: wrap;
}

.setting-row:last-child { margin-bottom: 0; }

.setting-row label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text);
    min-width: 110px;
}

.setting-row input[type="range"] {
    flex: 1;
    min-width: 100px;
    max-width: 200px;
}

.setting-row input[type="number"],
.setting-row input[type="text"] {
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
    border: 1px solid var(--color-border, #ddd);
    border-radius: var(--radius-md, 6px);
    width: 100px;
}

.setting-row input[type="text"] { width: 200px; }

.setting-row select {
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
    border: 1px solid var(--color-border, #ddd);
    border-radius: var(--radius-md, 6px);
    background: var(--color-surface);
    color: var(--color-text);
}

.setting-row input[type="color"] {
    width: 40px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm, 4px);
    cursor: pointer;
}

.setting-hint {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin: 0.5rem 0 0;
    font-style: italic;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    font-weight: 400;
    min-width: auto;
    cursor: pointer;
}

/* ── Process button ────────────────────────────────────────────────── */
.process-row {
    margin-top: 1.25rem;
    text-align: center;
}

.process-row .tool-button {
    min-width: 180px;
    padding: 0.65rem 1.5rem;
    font-size: 1rem;
}

.process-row .tool-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Meme preview ──────────────────────────────────────────────────── */
.meme-preview-area {
    position: relative;
    margin-top: 1.25rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #1a1a1a;
    border-radius: var(--radius-lg, 8px);
    overflow: hidden;
    min-height: 300px;
}

.meme-preview-area canvas {
    max-width: 100%;
    max-height: 600px;
    display: block;
}

.meme-text-handle {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px dashed var(--color-primary);
    border-radius: var(--radius-md, 6px);
    font-family: Impact, sans-serif;
    font-size: 14px;
    font-weight: bold;
    color: #333;
    cursor: move;
    user-select: none;
    z-index: 10;
    white-space: nowrap;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.meme-text-handle[data-pos="top"] { top: 10px; }
.meme-text-handle[data-pos="bottom"] { bottom: 10px; }

.meme-text-handle:hover {
    background: rgba(74, 144, 226, 0.2);
}

/* ── Editor tools ──────────────────────────────────────────────────── */
.editor-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.75rem;
}

.editor-slider-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-top: 0.75rem;
}

.editor-slider-row label {
    font-size: 0.85rem;
    font-weight: 600;
    min-width: 80px;
}

.editor-slider-row input[type="range"] {
    flex: 1;
    max-width: 300px;
}

/* ── Results ───────────────────────────────────────────────────────── */
.results-section {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border, #ddd);
    border-radius: var(--radius-lg, 8px);
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.results-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
}

.results-actions {
    display: flex;
    gap: 0.5rem;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}

.result-card {
    border: 1px solid var(--color-border, #ddd);
    border-radius: var(--radius-md, 6px);
    overflow: hidden;
    background: var(--color-bg, #f9f9f9);
}

.result-preview {
    aspect-ratio: 1;
    background: #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.result-preview img,
.result-preview svg {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.result-info {
    padding: 0.5rem;
    font-size: 0.75rem;
}

.result-name {
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.result-size {
    color: var(--color-text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-size .savings {
    color: #27ae60;
    font-weight: 600;
}

.result-actions {
    padding: 0.5rem;
    padding-top: 0;
    display: flex;
    gap: 0.35rem;
}

.result-actions button {
    flex: 1;
    padding: 0.3rem 0.5rem;
    font-size: 0.72rem;
}

.results-stats {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border, #ddd);
    font-size: 0.85rem;
    color: var(--color-text-muted);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.results-stats .stat-highlight {
    color: #27ae60;
    font-weight: 700;
}

/* ── SVG result special styling ────────────────────────────────────── */
.result-preview.svg-preview {
    background: repeating-conic-gradient(#ddd 0% 25%, #fff 0% 50%) 50% / 16px 16px;
}

/* ── Small buttons ─────────────────────────────────────────────────── */
.sm-btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.82rem;
}

.secondary-btn {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border, #ccc);
}

.secondary-btn:hover {
    background: var(--color-border, #e0e0e0);
}

/* ── Loading state ─────────────────────────────────────────────────── */
.processing {
    position: relative;
    pointer-events: none;
}

.processing::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .mode-tabs {
        gap: 0.25rem;
    }

    .mode-tab {
        padding: 0.4rem 0.65rem;
        font-size: 0.75rem;
    }

    .setting-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .setting-row label {
        min-width: auto;
    }

    .setting-row input[type="range"],
    .setting-row input[type="text"],
    .setting-row select {
        width: 100%;
        max-width: none;
    }

    .results-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }

    .upload-thumbs {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    }

    .editor-tools {
        justify-content: center;
    }
}

/* ── Preview area (shared for meme, watermark, blur) ─────────────── */
.preview-area {
    margin-top: 1.25rem;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border, #ddd);
    border-radius: var(--radius-lg, 8px);
    overflow: hidden;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    background: var(--color-bg, #f9f9f9);
    border-bottom: 1px solid var(--color-border, #ddd);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-text);
}

.preview-hint {
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.preview-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #1a1a1a;
    min-height: 300px;
    overflow: hidden;
}

.preview-container canvas {
    max-width: 100%;
    max-height: 600px;
    display: block;
}

/* ── Meme text handles ─────────────────────────────────────────────── */
#meme-handles {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.meme-handle {
    position: absolute;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.92);
    border: 2px dashed var(--color-primary);
    border-radius: var(--radius-sm, 4px);
    font-family: Impact, sans-serif;
    font-size: 12px;
    font-weight: bold;
    color: #333;
    cursor: move;
    user-select: none;
    pointer-events: auto;
    white-space: nowrap;
    max-width: 95%;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 10;
}

.meme-handle:hover {
    background: rgba(74, 144, 226, 0.25);
}

.meme-handle .handle-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 16px;
    height: 16px;
    border: none;
    border-radius: 50%;
    background: #c0392b;
    color: #fff;
    font-size: 10px;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
}

.meme-handle:hover .handle-remove {
    display: flex;
}

/* ── Watermark handles ─────────────────────────────────────────────── */
#watermark-handles {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.watermark-handle {
    position: absolute;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.8);
    border: 2px dashed #27ae60;
    border-radius: var(--radius-sm, 4px);
    font-size: 11px;
    font-weight: 600;
    color: #333;
    cursor: move;
    user-select: none;
    pointer-events: auto;
    z-index: 10;
}

.watermark-handle:hover {
    background: rgba(39, 174, 96, 0.2);
}

.watermark-handle .handle-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 16px;
    height: 16px;
    border: none;
    border-radius: 50%;
    background: #c0392b;
    color: #fff;
    font-size: 10px;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
}

.watermark-handle:hover .handle-remove {
    display: flex;
}

/* ── Blur overlay ──────────────────────────────────────────────────── */
#blur-overlay {
    position: absolute;
    inset: 0;
    cursor: crosshair;
}

.blur-region {
    position: absolute;
    border: 2px solid #e74c3c;
    background: rgba(231, 76, 60, 0.15);
    cursor: move;
}

.blur-region.drawing {
    pointer-events: none;
}

.blur-region .region-remove {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: #c0392b;
    color: #fff;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
}

.blur-region:hover .region-remove {
    display: flex;
}

/* ── Meme text field rows ──────────────────────────────────────────── */
.meme-text-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background: var(--color-bg, #f5f5f5);
    border-radius: var(--radius-md, 6px);
}

.meme-text-row input[type="text"] {
    flex: 1;
    min-width: 120px;
}

.meme-text-row .remove-text-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #e74c3c;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
}

.meme-text-row .remove-text-btn:hover {
    background: #c0392b;
}

/* ── HTML input textarea ───────────────────────────────────────────── */
.html-input {
    width: 100%;
    min-height: 200px;
    margin-top: 0.75rem;
    padding: 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    border: 1px solid var(--color-border, #ddd);
    border-radius: var(--radius-md, 6px);
    resize: vertical;
}

/* ── Python helper ─────────────────────────────────────────────────── */
.python-ops-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.4rem 1rem;
    margin-bottom: 1rem;
}

.python-ops-list .checkbox-label {
    font-size: 0.82rem;
}

.python-output {
    margin-top: 1rem;
    border: 1px solid var(--color-border, #ddd);
    border-radius: var(--radius-md, 6px);
    overflow: hidden;
}

.python-output-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: var(--color-bg, #f5f5f5);
    border-bottom: 1px solid var(--color-border, #ddd);
    font-size: 0.85rem;
    font-weight: 600;
}

.python-output pre {
    margin: 0;
    padding: 1rem;
    background: #1e1e1e;
    color: #d4d4d4;
    font-size: 0.82rem;
    line-height: 1.5;
    overflow-x: auto;
    max-height: 400px;
}

/* ── SVG preview fix ───────────────────────────────────────────────── */
.result-preview.svg-preview svg {
    width: 100%;
    height: 100%;
}

/* ── Editor toolbar ───────────────────────────────────────────────── */
.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    padding: 0.75rem;
    background: var(--color-bg, #f5f5f5);
    border-radius: var(--radius-md, 6px);
    margin-bottom: 0.75rem;
}

.editor-tool-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.tool-group-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-right: 0.25rem;
}

.editor-tool-btn {
    width: 32px;
    height: 32px;
    padding: 5px;
    border: 1px solid var(--color-border, #ddd);
    border-radius: var(--radius-sm, 4px);
    background: var(--color-surface, #fff);
    cursor: pointer;
    transition: all 0.15s;
}

.editor-tool-btn svg {
    width: 100%;
    height: 100%;
    stroke: var(--color-text);
}

.editor-tool-btn:hover {
    border-color: var(--color-primary);
}

.editor-tool-btn.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.editor-tool-btn.active svg {
    stroke: #fff;
}

.editor-layer-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

#editor-add-image {
    flex: 0 0 auto;
}

/* ── Editor layers panel ──────────────────────────────────────────── */
.editor-layers-panel {
    margin-top: 0.75rem;
    border: 1px solid var(--color-border, #ddd);
    border-radius: var(--radius-md, 6px);
    overflow: hidden;
    max-height: 200px;
}

.layers-panel-header {
    padding: 0.5rem 0.75rem;
    background: var(--color-bg, #f5f5f5);
    border-bottom: 1px solid var(--color-border, #ddd);
    font-size: 0.8rem;
    font-weight: 700;
}

.editor-layers-list {
    max-height: 150px;
    overflow-y: auto;
}

.layer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--color-border, #eee);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.1s;
}

.layer-item:last-child {
    border-bottom: none;
}

.layer-item:hover {
    background: var(--color-bg, #f9f9f9);
}

.layer-item.selected {
    background: rgba(74, 144, 226, 0.15);
    border-left: 3px solid var(--color-primary);
}

.layer-item.base-layer {
    color: var(--color-text-muted);
    font-style: italic;
    cursor: default;
}

.layer-item .layer-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.layer-item .layer-actions {
    display: flex;
    gap: 0.25rem;
}

.layer-item .layer-btn {
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm, 4px);
    background: transparent;
    color: var(--color-text-muted);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.layer-item .layer-btn:hover {
    background: var(--color-border, #ddd);
    color: var(--color-text);
}

.layer-item .layer-btn.delete:hover {
    background: #e74c3c;
    color: #fff;
}

/* ── Editor layer handles (image overlays) ────────────────────────── */
#editor-layers-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.editor-layer {
    position: absolute;
    cursor: move;
    pointer-events: auto;
    border: 2px solid transparent;
    box-sizing: border-box;
}

.editor-layer:hover,
.editor-layer.selected {
    border-color: var(--color-primary);
}

.editor-layer img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.editor-layer .resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--color-primary);
    border: 2px solid #fff;
    border-radius: 2px;
    cursor: nwse-resize;
    display: none;
}

.editor-layer.selected .resize-handle {
    display: block;
}

.editor-layer .resize-handle.nw { top: -6px; left: -6px; cursor: nwse-resize; }
.editor-layer .resize-handle.ne { top: -6px; right: -6px; cursor: nesw-resize; }
.editor-layer .resize-handle.sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.editor-layer .resize-handle.se { bottom: -6px; right: -6px; cursor: nwse-resize; }

.editor-layer .rotate-handle {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    background: var(--color-primary);
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: grab;
    display: none;
}

.editor-layer.selected .rotate-handle {
    display: block;
}

.editor-layer .delete-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: #e74c3c;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
}

.editor-layer.selected .delete-btn {
    display: flex;
}

/* ── Metadata display ─────────────────────────────────────────────── */
.metadata-display {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--color-bg, #f9f9f9);
    border-radius: var(--radius-md, 6px);
    max-height: 300px;
    overflow-y: auto;
}

.metadata-display h4 {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    font-weight: 700;
}

.metadata-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.metadata-item {
    padding: 0.5rem;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border, #ddd);
    border-radius: var(--radius-sm, 4px);
}

.metadata-item-name {
    font-weight: 600;
    font-size: 0.8rem;
    margin-bottom: 0.35rem;
    color: var(--color-text);
}

.metadata-item-data {
    font-size: 0.7rem;
    font-family: var(--font-mono, monospace);
    color: var(--color-text-muted);
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 150px;
    overflow-y: auto;
}

.metadata-diff {
    font-size: 0.7rem;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: #fef3e2;
    border-radius: var(--radius-sm, 4px);
}

.metadata-diff .removed {
    color: #c0392b;
    text-decoration: line-through;
}

/* ── Python preview ───────────────────────────────────────────────── */
.python-ops-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.python-op-item {
    padding: 0.5rem 0.75rem;
    background: var(--color-bg, #f9f9f9);
    border-radius: var(--radius-md, 6px);
}

.python-op-item .checkbox-label {
    font-weight: 600;
}

.python-op-item .op-desc {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin: 0.25rem 0 0 1.4rem;
}

.python-op-item .op-params {
    display: none;
    margin: 0.5rem 0 0 1.4rem;
    padding: 0.5rem;
    background: var(--color-surface, #fff);
    border-radius: var(--radius-sm, 4px);
    font-size: 0.8rem;
}

.python-op-item .op-params label {
    margin-right: 0.5rem;
}

.python-op-item .op-params input[type="range"] {
    width: 100px;
    vertical-align: middle;
}

.python-op-item .checkbox-label input:checked ~ .op-desc + .op-params,
.python-op-item:has(.checkbox-label input:checked) .op-params {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.python-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.python-preview-area {
    margin-top: 1rem;
    border: 1px solid var(--color-border, #ddd);
    border-radius: var(--radius-md, 6px);
    overflow: hidden;
}

.python-preview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--color-border, #ddd);
}

.python-preview-item {
    background: #1a1a1a;
    padding: 0.5rem;
    text-align: center;
}

.python-preview-item span {
    display: block;
    font-size: 0.75rem;
    color: #aaa;
    margin-bottom: 0.35rem;
}

.python-preview-item canvas {
    max-width: 100%;
    max-height: 250px;
    background: #000;
}

/* ── HTML preview ─────────────────────────────────────────────────── */
.html-preview-area {
    margin-top: 1rem;
    border: 1px solid var(--color-border, #ddd);
    border-radius: var(--radius-md, 6px);
    overflow: hidden;
}

.html-preview-container {
    background: #fff;
    min-height: 200px;
    max-height: 500px;
    overflow: auto;
}

.html-preview-container iframe {
    width: 100%;
    height: 400px;
    border: none;
}

.url-source-settings input[type="url"] {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    border: 1px solid var(--color-border, #ddd);
    border-radius: var(--radius-md, 6px);
}

/* ── Responsive adjustments ───────────────────────────────────────── */
@media (max-width: 640px) {
    .editor-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .python-preview-grid {
        grid-template-columns: 1fr;
    }
}
