.tool-block {
    padding: 0;
}

/* ========== Top bar (editor-style, one strip) ========== */
.or-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 0.65rem 0.75rem;
    padding: 0.875rem 1.25rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border, rgba(148, 163, 184, 0.12));
}

.or-bar-brand {
    flex: 0 0 auto;
    min-width: 9rem;
    padding-right: 0.25rem;
}

.or-brand {
    display: block;
    font-size: 0.8rem;
    color: var(--accent, #00d4aa);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.or-bar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
}

.or-bar-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 0.55rem 0.7rem;
    min-width: 0;
}

/* Uniform action buttons (same footprint as other services) */
.or-btn {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 8.5rem;
    height: 2.15rem;
    padding: 0 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border, rgba(148, 163, 184, 0.12));
    background: transparent;
    color: var(--text-secondary, #94a3b8);
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.8rem;
    line-height: 1;
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}

.or-btn:hover {
    color: var(--text-primary, #f1f5f9);
    border-color: rgba(148, 163, 184, 0.35);
    background: rgba(148, 163, 184, 0.05);
    transform: translateY(-1px);
}

.or-btn--primary {
    background: var(--accent, #00d4aa);
    color: var(--bg-primary, #0a0e17);
    border-color: var(--accent, #00d4aa);
    font-weight: 600;
}

.or-btn--primary:hover {
    opacity: 0.92;
    color: var(--bg-primary, #0a0e17);
    background: var(--accent, #00d4aa);
    border-color: var(--accent, #00d4aa);
}

.or-btn--accent {
    background: transparent;
    color: var(--accent, #00d4aa);
    border-color: rgba(0, 212, 170, 0.45);
}

.or-btn--accent:hover {
    background: rgba(0, 212, 170, 0.1);
    color: var(--accent, #00d4aa);
    border-color: rgba(0, 212, 170, 0.7);
}

.or-divider {
    width: 1px;
    height: 1.55rem;
    background: rgba(148, 163, 184, 0.18);
    flex: 0 0 auto;
}

/* Segmented tool switch */
.or-seg {
    display: inline-flex;
    padding: 3px;
    border-radius: 10px;
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.14);
    gap: 2px;
}

.or-seg-btn {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--text-secondary, #94a3b8);
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.74rem;
    line-height: 1.2;
    padding: 0.42rem 0.7rem;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.or-seg-btn:hover {
    color: var(--text-primary, #f1f5f9);
    background: rgba(148, 163, 184, 0.08);
}

.or-seg-btn.is-active {
    color: #041018;
    background: var(--accent, #00d4aa);
    box-shadow: 0 0 0 1px rgba(0, 212, 170, 0.35);
}

.or-field--presets {
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
}

.or-seg--presets .or-seg-btn {
    padding: 0.38rem 0.55rem;
    font-size: 0.7rem;
}

.or-preset-tip {
    flex: 1 1 100%;
    margin: 0;
    padding: 0 0.15rem;
    font-size: 0.78rem;
    line-height: 1.35;
    color: var(--text-secondary, #94a3b8);
}

/* Compact fields */
.or-field {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 2rem;
}

.or-field-label {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.66rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(148, 163, 184, 0.85);
    white-space: nowrap;
}

.or-field-value {
    min-width: 1.4rem;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.74rem;
    color: var(--text-primary, #f1f5f9);
    font-variant-numeric: tabular-nums;
}

.or-field input[type="range"] {
    width: 88px;
    margin: 0;
    accent-color: var(--accent, #00d4aa);
    background: transparent;
    cursor: pointer;
}

.or-select {
    appearance: none;
    min-width: 9.5rem;
    padding: 0.38rem 1.7rem 0.38rem 0.55rem;
    border-radius: 7px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(17, 24, 39, 0.9)
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%9494a3' d='M3 4.5 6 8l3-3.5'/%3E%3C/svg%3E")
        no-repeat right 0.45rem center;
    color: var(--text-primary, #f1f5f9);
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.72rem;
    cursor: pointer;
}

.or-select:focus {
    outline: none;
    border-color: rgba(0, 212, 170, 0.55);
}

.or-file {
    cursor: pointer;
}

/* Lock toolbar while LaMa request is in flight (overlay only covers the stage) */
.or-bar.is-busy {
    opacity: 0.72;
    pointer-events: none;
    user-select: none;
}

.or-bar.is-busy .or-btn,
.or-bar.is-busy .or-seg-btn,
.or-bar.is-busy .or-select,
.or-bar.is-busy .or-field input[type="range"] {
    cursor: wait;
}


/* ========== Stage ========== */
.or-stage {
    position: relative;
    min-height: 380px;
    height: min(72vh, 680px);
    display: flex;
    align-items: center;
    justify-content: center;
    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;
    overflow: hidden;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.or-stage.is-panning,
.or-stage.is-panning .or-viewport #or-overlay,
.or-stage[data-tool="pan"] .or-viewport #or-overlay {
    cursor: grab;
}

.or-stage.is-panning .or-viewport #or-overlay {
    cursor: grabbing;
}

.or-workspace {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.or-dropzone {
    position: relative;
    z-index: 1;
    width: min(100%, 480px);
    margin: 1rem;
    padding: 2.75rem 1.5rem;
    border: 1px dashed rgba(148, 163, 184, 0.28);
    border-radius: 14px;
    text-align: center;
    cursor: pointer;
    background: rgba(10, 14, 23, 0.45);
    backdrop-filter: blur(4px);
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.or-dropzone:hover,
.or-dropzone.is-dragover {
    border-color: rgba(0, 212, 170, 0.65);
    background: rgba(0, 212, 170, 0.07);
    transform: translateY(-1px);
}

.or-dropzone-title {
    margin: 0 0 0.45rem;
    color: var(--text-primary, #f1f5f9);
    font-size: 1.02rem;
    font-weight: 500;
}

.or-dropzone-hint {
    margin: 0;
    color: var(--text-muted, #64748b);
    font-size: 0.84rem;
    line-height: 1.45;
}

.or-viewport {
    position: absolute;
    left: 0;
    top: 0;
    display: inline-block;
    line-height: 0;
    border-radius: 10px;
    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;
}

.or-viewport #or-image {
    display: block;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    vertical-align: top;
}

.or-viewport #or-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: none;
    touch-action: none;
}

.or-cursor {
    position: absolute;
    top: 0;
    left: 0;
    width: 28px;
    height: 28px;
    margin: 0;
    border: 2px solid rgba(255, 80, 80, 0.95);
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
    pointer-events: none;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.or-cursor.is-eraser {
    border-color: rgba(148, 163, 184, 0.95);
}

.or-cursor.is-pan {
    display: none;
}

/* Floating HUD on canvas */
.or-hud {
    position: absolute;
    right: 0.75rem;
    bottom: 0.75rem;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.4rem;
    pointer-events: none;
}

.or-zoom {
    display: inline-flex;
    pointer-events: auto;
    padding: 3px;
    border-radius: 10px;
    background: rgba(8, 12, 20, 0.82);
    border: 1px solid rgba(148, 163, 184, 0.18);
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.or-zoom-btn {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--text-secondary, #94a3b8);
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.78rem;
    min-width: 2rem;
    height: 2rem;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.or-zoom-btn:hover {
    color: var(--text-primary, #f1f5f9);
    background: rgba(148, 163, 184, 0.12);
}

.or-zoom-pct {
    min-width: 3.4rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary, #f1f5f9);
}

.or-hud-hint {
    margin: 0;
    padding: 0.28rem 0.5rem;
    border-radius: 6px;
    background: rgba(8, 12, 20, 0.72);
    color: rgba(148, 163, 184, 0.9);
    font-size: 0.66rem;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    line-height: 1.35;
    max-width: 16rem;
    text-align: right;
}

/* Status */
.tool-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1rem;
    background: rgba(0, 212, 170, 0.04);
    min-height: 40px;
}

.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="ok"] { background: rgba(0, 212, 170, 0.07); }
.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.07); }
.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.07); }
.tool-status[data-state="warn"] .tool-status-dot { background: #f59e0b; }
.tool-status[data-state="warn"] .tool-status-text { color: #fcd34d; }

.tool-status[data-state="processing"] { background: rgba(56, 189, 248, 0.07); }
.tool-status[data-state="processing"] .tool-status-dot {
    background: #38bdf8;
    animation: or-pulse 1s ease-in-out infinite;
}
.tool-status[data-state="processing"] .tool-status-text { color: #7dd3fc; }

@keyframes or-pulse {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 1; }
}

/* Processing overlay on photo */
.or-stage.is-processing .or-viewport {
    animation: or-photo-pulse 1.45s ease-in-out infinite;
    filter: saturate(0.8) brightness(0.88);
}

.or-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;
}

.or-process[hidden] {
    display: none !important;
}

.or-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: or-scan 2.1s ease-in-out infinite;
    pointer-events: none;
}

.or-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);
}

.or-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: or-spin 0.75s linear infinite;
}

.or-process-text {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.82rem;
    line-height: 1.3;
    color: var(--text-primary, #f1f5f9);
}

@keyframes or-photo-pulse {
    0%, 100% { opacity: 0.62; }
    50% { opacity: 0.9; }
}

@keyframes or-scan {
    0% { top: -30%; opacity: 0; }
    15% { opacity: 1; }
    85% { opacity: 1; }
    100% { top: 105%; opacity: 0; }
}

@keyframes or-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 960px) {
    .or-bar-brand {
        min-width: 0;
        width: 100%;
    }

    .or-btn {
        min-width: calc(50% - 0.25rem);
        flex: 1 1 calc(50% - 0.25rem);
    }

    .or-divider {
        display: none;
    }

    .or-field input[type="range"] {
        width: 72px;
    }

    .or-stage {
        min-height: 280px;
    }

    .or-hud-hint {
        display: none;
    }
}
