/* image-pixelate-sensitive-data — region canvas + FFmpeg pixelate */

.tool-block {
    padding: 0;
    font-family: var(--font-ui, 'Inter', system-ui, sans-serif);
}

.tool-block [hidden] {
    display: none !important;
}

.tool-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.25rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border, rgba(148, 163, 184, 0.12));
}

.tool-label {
    font-size: 0.8rem;
    color: var(--accent, #00d4aa);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tool-toolbar-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tool-btn,
a.tool-btn,
a.tool-btn:link,
a.tool-btn:visited {
    padding: 0.65rem 1rem;
    min-height: 2.5rem;
    box-sizing: border-box;
    font-size: 0.85rem;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    background: var(--accent, #00d4aa);
    color: var(--bg-primary, #0a0e17);
    border: none;
    border-radius: var(--radius-sm, 8px);
    cursor: pointer;
    transition: opacity var(--transition, 0.2s ease), transform var(--transition, 0.2s ease);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
}

.tool-btn:hover,
a.tool-btn:hover,
a.tool-btn:focus-visible {
    opacity: 0.9;
    transform: translateY(-1px);
    color: var(--bg-primary, #0a0e17);
    text-decoration: none;
}

.tool-btn-secondary,
a.tool-btn-secondary,
a.tool-btn-secondary:link,
a.tool-btn-secondary:visited {
    background: transparent;
    color: var(--text-secondary, #94a3b8);
    border: 1px solid var(--border, rgba(148, 163, 184, 0.12));
}

.tool-btn-secondary:hover,
a.tool-btn-secondary:hover,
a.tool-btn-secondary:focus-visible {
    color: var(--text-primary, #f1f5f9);
    border-color: var(--border-accent, rgba(0, 212, 170, 0.3));
    background: var(--accent-dim, rgba(0, 212, 170, 0.08));
    opacity: 1;
}

.tool-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.tool-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: rgba(0, 0, 0, 0.1);
    border-top: 1px solid var(--border, rgba(148, 163, 184, 0.12));
}

.tool-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted, #64748b);
    flex-shrink: 0;
}

.tool-status-text {
    font-size: 0.8rem;
    color: var(--text-muted, #64748b);
}

.tool-status[data-state="idle"] .tool-status-dot { background: var(--text-muted, #64748b); }

.tool-status[data-state="loading"] {
    background: rgba(56, 189, 248, 0.07);
}

.tool-status[data-state="loading"] .tool-status-dot {
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    width: 12px;
    height: 12px;
    background: transparent;
    animation: tool-spin 0.8s linear infinite;
    color: #38bdf8;
}

.tool-status[data-state="loading"] .tool-status-text {
    color: #7dd3fc;
}

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

/* Processing overlay on photo */
.ipsd-stage.is-processing .ipsd-viewport {
    animation: ipsd-photo-pulse 1.45s ease-in-out infinite;
    filter: saturate(0.8) brightness(0.88);
}

.ipsd-process {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(8, 12, 20, 0.34);
    backdrop-filter: blur(1.5px);
    pointer-events: all;
    cursor: wait;
}

.ipsd-process[hidden] {
    display: none !important;
}

.ipsd-process::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 28%;
    background: linear-gradient(
        180deg,
        transparent 0%,
        rgba(0, 212, 170, 0.1) 45%,
        transparent 100%
    );
    animation: ipsd-scan 2.1s ease-in-out infinite;
    pointer-events: none;
}

.ipsd-process-card {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    max-width: min(92%, 22rem);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 1px solid rgba(0, 212, 170, 0.28);
    background: rgba(10, 14, 23, 0.88);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.ipsd-process-spinner {
    width: 1.05rem;
    height: 1.05rem;
    border-radius: 50%;
    border: 2px solid rgba(0, 212, 170, 0.25);
    border-top-color: var(--accent, #00d4aa);
    flex-shrink: 0;
    animation: tool-spin 0.75s linear infinite;
}

.ipsd-process-text {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.82rem;
    line-height: 1.3;
    color: var(--text-primary, #f1f5f9);
}

@keyframes ipsd-photo-pulse {
    0%, 100% { opacity: 0.62; }
    50% { opacity: 0.9; }
}

@keyframes ipsd-scan {
    0% { top: -30%; opacity: 0; }
    15% { opacity: 1; }
    85% { opacity: 1; }
    100% { top: 105%; opacity: 0; }
}

.tool-status[data-state="ok"] { background: rgba(0, 212, 170, 0.08); }
.tool-status[data-state="ok"] .tool-status-dot { background: var(--success, #22c55e); }
.tool-status[data-state="ok"] .tool-status-text { color: var(--success, #22c55e); }
.tool-status[data-state="error"] { background: rgba(239, 68, 68, 0.08); }
.tool-status[data-state="error"] .tool-status-dot { background: var(--danger, #ef4444); }
.tool-status[data-state="error"] .tool-status-text { color: #fca5a5; }
.tool-status[data-state="warn"] { background: rgba(245, 158, 11, 0.08); }
.tool-status[data-state="warn"] .tool-status-dot { background: #f59e0b; }
.tool-status[data-state="warn"] .tool-status-text { color: #fcd34d; }

.mono { font-family: var(--font-mono, 'JetBrains Mono', monospace); }

.tool-slider {
    width: 100%;
    accent-color: var(--accent, #00d4aa);
}

.ipsd-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.ipsd-dropzone {
    border: 1px dashed rgba(148, 163, 184, 0.28);
    border-radius: var(--radius-sm, 8px);
    padding: 2rem 1.25rem;
    text-align: center;
    cursor: pointer;
    background:
        linear-gradient(180deg, rgba(0, 212, 170, 0.04), transparent 55%),
        rgba(0, 0, 0, 0.12);
    transition: border-color var(--transition, 0.2s ease), background var(--transition, 0.2s ease), transform var(--transition, 0.2s ease);
    outline: none;
}

.ipsd-dropzone:hover,
.ipsd-dropzone:focus-visible {
    border-color: var(--border-accent, rgba(0, 212, 170, 0.55));
    background:
        linear-gradient(180deg, rgba(0, 212, 170, 0.08), transparent 55%),
        rgba(0, 0, 0, 0.16);
}

.ipsd-dropzone.is-dragover {
    border-color: var(--accent, #00d4aa);
    border-style: solid;
    transform: translateY(-1px);
    box-shadow: inset 0 0 0 1px var(--accent-dim, rgba(0, 212, 170, 0.25));
}

.ipsd-dropzone.has-file { padding: 1.25rem; cursor: default; }

.ipsd-dropzone-visual { display: flex; justify-content: center; margin-bottom: 0.75rem; }

.ipsd-dropzone.has-file .ipsd-dropzone-visual,
.ipsd-dropzone.has-file .ipsd-dropzone-copy { display: none; }

.ipsd-dropzone-icon { width: 48px; height: 48px; color: var(--accent, #00d4aa); opacity: 0.9; }

.ipsd-dropzone-title { margin: 0 0 0.35rem; font-size: 1rem; color: var(--text-primary, #f1f5f9); }

.ipsd-dropzone-hint { margin: 0; font-size: 0.8rem; color: var(--text-muted, #64748b); }

.ipsd-file-chip { display: flex; flex-direction: column; align-items: center; gap: 0.85rem; }

.ipsd-file-chip-info { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; max-width: 100%; }

.ipsd-file-chip-name { color: var(--text-primary, #f1f5f9); font-size: 0.85rem; word-break: break-all; }

.ipsd-file-chip-meta { color: var(--text-muted, #64748b); font-size: 0.75rem; }

.ipsd-file-chip-btn { margin-top: 0.15rem; }

.ipsd-canvas-section { display: flex; flex-direction: column; gap: 0.75rem; }

.ipsd-stage {
    position: relative;
    width: 100%;
    min-height: 420px;
    height: min(72vh, 720px);
    background:
        radial-gradient(1200px 400px at 50% 0%, rgba(0, 212, 170, 0.05), transparent 55%),
        repeating-conic-gradient(#182231 0 25%, #121a26 0 50%) 0 / 22px 22px;
    border: 1px solid var(--border, rgba(148, 163, 184, 0.12));
    border-radius: 10px;
    overflow: hidden;
}

.ipsd-stage.is-panning,
.ipsd-stage.is-panning .ipsd-canvas-overlay { cursor: grabbing; }

.ipsd-workspace { position: absolute; inset: 0; overflow: hidden; }

.ipsd-viewport {
    position: absolute;
    left: 0;
    top: 0;
    display: inline-block;
    line-height: 0;
    border-radius: 8px;
    box-shadow:
        0 0 0 1px rgba(148, 163, 184, 0.14),
        0 18px 40px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    transform-origin: 0 0;
    will-change: transform;
}

.ipsd-viewport canvas {
    display: block;
    max-width: none;
    max-height: none;
    width: auto;
    height: auto;
    vertical-align: top;
}

.ipsd-canvas-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

.ipsd-hud {
    position: absolute;
    left: 0.75rem;
    bottom: 0.75rem;
    z-index: 3;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem 0.85rem;
    padding: 0.45rem 0.65rem;
    border-radius: 10px;
    background: rgba(10, 14, 23, 0.78);
    border: 1px solid rgba(148, 163, 184, 0.16);
    backdrop-filter: blur(6px);
    max-width: calc(100% - 1.5rem);
}

.ipsd-zoom { display: inline-flex; align-items: center; gap: 2px; }

.ipsd-zoom-btn {
    appearance: none;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(148, 163, 184, 0.08);
    color: var(--text-primary, #f1f5f9);
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.85rem;
    min-width: 2rem;
    height: 2rem;
    border-radius: 6px;
    cursor: pointer;
}

.ipsd-zoom-btn:hover {
    border-color: rgba(0, 212, 170, 0.45);
    color: var(--accent, #00d4aa);
}

.ipsd-zoom-pct { min-width: 3.4rem; font-size: 0.72rem; }

.ipsd-hud-hint {
    margin: 0;
    font-size: 0.72rem;
    color: var(--text-muted, #64748b);
    line-height: 1.3;
}

.ipsd-region-rect {
    position: absolute;
    border: 2px solid var(--danger, #ef4444);
    background: rgba(239, 68, 68, 0.12);
    box-sizing: border-box;
    pointer-events: none;
}

.ipsd-region-preview { background: rgba(239, 68, 68, 0.08); }

.ipsd-region-hint { margin: 0; font-size: 0.8rem; color: var(--text-muted, #64748b); }

.ipsd-controls {
    display: grid;
    gap: 1rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--border, rgba(148, 163, 184, 0.12));
    border-radius: var(--radius-sm, 8px);
    background: rgba(0, 0, 0, 0.14);
}

.ipsd-mode { display: grid; gap: 0.55rem; }

.ipsd-mode-label {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary, #94a3b8);
}

.ipsd-mode-seg {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 3px;
    border-radius: 10px;
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.14);
    width: fit-content;
    max-width: 100%;
}

.ipsd-mode-btn {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--text-secondary, #94a3b8);
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.78rem;
    line-height: 1.2;
    padding: 0.5rem 0.85rem;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.ipsd-mode-btn:hover {
    color: var(--text-primary, #f1f5f9);
    background: rgba(148, 163, 184, 0.08);
}

.ipsd-mode-btn.is-active {
    color: #041018;
    background: var(--accent, #00d4aa);
}

.ipsd-mode-hint {
    margin: 0;
    font-size: 0.78rem;
    color: var(--text-muted, #64748b);
    line-height: 1.4;
}

.ipsd-field { display: flex; flex-direction: column; gap: 0.35rem; }

.ipsd-field-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.ipsd-field-head label { font-size: 0.9rem; color: var(--text-primary, #f1f5f9); }

.ipsd-field-value {
    min-width: 2rem;
    text-align: right;
    color: var(--accent, #00d4aa);
    font-size: 0.95rem;
}

.ipsd-field-hint { margin: 0.45rem 0 0; font-size: 0.78rem; color: var(--text-muted, #64748b); }

.ipsd-region-list { display: grid; gap: 0.5rem; }

.ipsd-region-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border, rgba(148, 163, 184, 0.12));
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.12);
}

.ipsd-region-item-index { color: var(--accent, #00d4aa); font-size: 0.8rem; min-width: 1.5rem; }

.ipsd-region-item-coords { color: var(--text-secondary, #94a3b8); font-size: 0.75rem; flex: 1; }

.ipsd-region-delete { padding: 0.35rem 0.6rem; min-height: 1.8rem; font-size: 0.75rem; }

.ipsd-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

.ipsd-primary { flex: 2; }

.ipsd-result {
    display: grid;
    gap: 0.85rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--border-accent, rgba(0, 212, 170, 0.22));
    border-radius: var(--radius-sm, 8px);
    background: var(--accent-dim, rgba(0, 212, 170, 0.05));
}

.ipsd-result-head { display: flex; align-items: center; }

.ipsd-result-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary, #94a3b8);
}

.ipsd-result-stats strong { color: var(--text-primary, #f1f5f9); font-weight: 500; }

.ipsd-history {
    border-top: 1px solid var(--border, rgba(148, 163, 184, 0.12));
    padding: 1.1rem 1.25rem 1.35rem;
    background: rgba(0, 0, 0, 0.08);
}

.ipsd-history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

.ipsd-history-title {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--accent, #00d4aa);
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
}

.ipsd-history-note { margin: 0 0 0.85rem; font-size: 0.75rem; color: var(--text-muted, #64748b); }

.ipsd-history-empty { font-size: 0.85rem; color: var(--text-secondary, #94a3b8); padding: 0.75rem 0; }

.ipsd-history-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.65rem; }

.ipsd-history-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.65rem 1rem;
    align-items: center;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--border, rgba(148, 163, 184, 0.12));
    border-radius: var(--radius-sm, 8px);
    background: rgba(17, 24, 39, 0.55);
}

.ipsd-history-main { min-width: 0; }

.ipsd-history-name {
    display: block;
    font-size: 0.85rem;
    color: var(--text-primary, #f1f5f9);
    word-break: break-all;
    margin-bottom: 0.25rem;
}

.ipsd-history-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    font-size: 0.72rem;
    color: var(--text-muted, #64748b);
}

.ipsd-history-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: flex-end; }

@media (max-width: 576px) {
    .tool-toolbar { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .ipsd-history-item { grid-template-columns: 1fr; }
    .ipsd-history-actions { justify-content: flex-start; }
    .ipsd-canvas-stage { max-width: 100%; overflow-x: auto; }
    .ipsd-actions { flex-direction: column; }
    .ipsd-primary { width: 100%; }
}
