/* image-blur-face — manual region selection + server-side FFmpeg blur */

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

.tool-block {
    padding: 0;
}

.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: 6px;
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.15s 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: rgba(148, 163, 184, 0.35);
    opacity: 1;
}

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

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

.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="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 !important;
    color: #38bdf8;
    animation: bf-spin 0.8s linear infinite;
}

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

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

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

.bf-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;
}

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

.bf-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: bf-scan 2.1s ease-in-out infinite;
    pointer-events: none;
}

.bf-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);
}

.bf-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: bf-spin 0.75s linear infinite;
}

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

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

@keyframes bf-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(--accent, #00d4aa);
}

.tool-status[data-state="ok"] .tool-status-text {
    color: var(--accent, #00d4aa);
}

.tool-status[data-state="error"] {
    background: rgba(239, 68, 68, 0.08);
}

.tool-status[data-state="error"] .tool-status-dot {
    background: #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;
}

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

.bf-dropzone {
    border: 1px dashed rgba(148, 163, 184, 0.28);
    border-radius: 10px;
    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 0.15s ease, background 0.15s ease, transform 0.15s ease;
    outline: none;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

.bf-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;
}

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

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

.bf-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;
}

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

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

.bf-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);
}

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

.bf-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;
}

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

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

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

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

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

.bf-region-hint {
    margin: 0;
    font-size: 0.78rem;
    color: var(--text-muted, #64748b);
    line-height: 1.4;
    text-align: center;
    width: 100%;
}

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

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

.bf-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);
}

.bf-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%;
}

.bf-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;
}

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

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

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

.bf-blur-quality {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

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

.bf-quality-head label {
    font-size: 0.8rem;
    color: var(--text-secondary, #94a3b8);
}

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

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

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

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

.bf-region-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border, rgba(148, 163, 184, 0.12));
    border-radius: 8px;
    background: rgba(17, 24, 39, 0.55);
}

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

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

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

.bf-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.bf-clear-regions-btn,
.bf-blur-btn {
    width: 100%;
}

.bf-result {
    display: grid;
    gap: 0.85rem;
    padding: 1rem 1.1rem;
    border: 1px solid rgba(0, 212, 170, 0.22);
    border-radius: 10px;
    background: rgba(0, 212, 170, 0.05);
}

.bf-result-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

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

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

.bf-result #download-link {
    width: 100%;
}

.bf-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);
}

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

.bf-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);
}

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

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

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

.bf-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: 8px;
    background: rgba(17, 24, 39, 0.55);
}

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

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

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

.bf-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;
    }

    .bf-history-item {
        grid-template-columns: 1fr;
    }

    .bf-history-actions {
        justify-content: flex-start;
    }

    .bf-canvas-stage {
        max-width: 100%;
        overflow-x: auto;
    }
}
